code contest

Pages: 1... 789
@chrisname
Don't you know you're supposed to use malloc() for reserving memory, like for x? ~.~

-Albatross
No, you only have to use malloc() if you're going to use free() so that you can use the memory again later :P If you don't want to use the memory again, you don't need to use malloc().
closed account (D80DSL3A)
But you did use the memory again, when reminding x of it's value!
x = strlen("hello world") * 4 - 2; // in case x forgot its value
You're right! This must be why my code didn't compile! Thanks guys.

Here's the revised version:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <conio.h>
#include <curses.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <windows.h>
#include <algorithm>
#include <stdio.h>
#include <stdint.h>
#include <cmath>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

using namespace std;

void main(int argc, char* argv[])
{
	int* x = malloc(std::string("2").size());
	for (float i = 0; i < argc; ++i)
		printf(std::string("hello, world").c_str());
	cout << flush;
	x = strlen("hello world") * 4 - 2;
	cout << "Press any key to continue...";
	getch();
	system("cls");
	clrscr();
	refresh();
	*x = strlen("hello world") * 4 - 2; // in case x forgot its value
	free(x); // make x free so it can be used without any performance cost
	exit(log10(pow(10, 42)) - x);
}
Last edited on
Simple password program. I have 4 more characters added but it takes up a lot of space so I'll save everyone's time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
char G = 32;
char L = 32;
string password;
string tries;
long time = 1;
int cont = 1;
while (1)
{
      if (password == "1")
      {
                   cout << endl;
      }
      cout << "Password tester\nUp to two characters\n\n";
      cin >> password;
G = 32;
L = 32;
time = 1;
cont = 1;
while (cont == 1)
{
      if (tries == password)
      {
                break;
      }
      G++;
      time++;
      tries = G;
      if (G == 127)
      {
            G = 32;
            cout << cont << endl;
            cont++;
      }
}
while (cont == 2)
{
      if (tries == password)
      {
                break;
      }
      L++;
      time++;
      tries = G;
      tries += L;
      if (L == 127)
      {
            G++;
            if (G == 127 && L == 127)
            {
                  G = 32;
                  cout << cont << endl;
                  cont++;
            }
            L = 32;
      }
}
      cout << endl << time << " tries.\nPassword:  " << tries << endl;

      cout << "\nEnter 1 to start over.\nEnter any other character to quit\n\n";
      cin >> password;
      if (password != "1")
      {
                   break;      
      }
}
}
@GRex: lol? Is this a troll? How long have you been programming?
Yeah. Sorry for all that waste. Only programming since last semester and don't have anyone to teach me anything. I'm happy that I can actually use strings. It's really slow after the third character but i'm proud of it. When I take my programming class next year it'll be better. I'll take any suggestions including removal of the eyesore.

Dang. I can't delete it anymore. Sorry everybody, guess I ruined the competition.
Last edited on
so as of right now i have only:
micah butler and stupebrett????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
This didn't work out very well.
i can easily agree.... did anyone else submit and i just didnt git the program????????
I think the problem is you've asked people to come up with competition-quality content in a period when people have the least free time and given them only a few weeks.

I bet if you tried again during the summer and gave them slightly more time and a better description for the theme of coding rather than just 'cool' then more people would join in.
I think a "code contest" could work really well. Look at Ludum Dare! However it needs to be more formal. Have an actual sign up, and prizes. Get people involved. Have a specific programming goal in mind and specific judging criteria. With all that I guarantee you'd have some good participation.
So yeah, jazz it up a little and get people to program something more specific. That would work quite well, it would certainly get me excited.
ok thanx fer the info and i am really really sorry for any disapointment
Topic archived. No new replies allowed.
Pages: 1... 789