C++ Beginners Challenge

The project is to make the "Hello World" program, but make it as rotten as possible. Anyone can make a crappy program, but it takes pure talent to make a real stinkbomb.

http://www.cppbeginners.com/showthread.php?t=9

Fun for beginners and pros.
There will be no epic win today...
I've got an epic win for you.

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
#include <iostream>
#include <string>

using namespace std;

template<int position>
class OneLetter {
  virtual void print() = 0;
};

template<>
class OneLetter<1> {
public:
  void print() { cout << "H"; }
};

template<>
class OneLetter<2> {
public:
  void print() { cout << "e"; }
};

template<>
class OneLetter<3> {
public:
  void print() { cout << "l"; }
};

int main() {

  OneLetter<1> letterH = OneLetter<1>();
  letterH.print();

  OneLetter<2> letterE = OneLetter<2>();
  letterE.print();

  OneLetter<3> letterL = OneLetter<3>();
  letterL.print();

  return 0;

}
Hahaha - Epic win! But it is the next day :)
Last edited on
No idea on how many systems and compilers this will work. Probably not on many. It at least works on Win32 with VC++ and MinGW.

1
2
3
4
5
6
7
8
9
10
11
12
#include <cstdio>
#include <cstring>

int main(){
	int a=0xEFBEADDE,b=0xEFBEADDE;
	strcpy((char*)(&b)-8-((char*)(&a)-(char*)(&b)-sizeof(int)),"Hello, ");
	char Hello[8];
	printf(Hello);
	strcpy(Hello,"World!\n");
	printf(Hello);
	return 0;
}
Last edited on
That looks freaky man
I'm not nearly that creative...
1
2
3
#define it int main(){printf("Hello World!");return 0;}
#include<iostream>
it
Last edited on
rofl lol
I like seymore's most :P
Like it too :]

Here's mine:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;

int main(int argc, char** argv) {

  if ( argc < 2 )
    system((string(argv[0])+string(" \"Hello World!\"")).c_str());
  else
    cout << argv[1];

  return EXIT_SUCCESS;

}
Now that's something, there!
I couldn't resist participating in this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

int main()
{
  bool spoke = true;
  speak:
  spoke = !spoke;
  cout << (spoke ? "World!" : "Hello ");
  if (!spoke) 
    goto speak;
  else
    cout << endl;
  return 0;
}


~psault
Last edited on
We have a goto :O! Give that man some cake!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
                 O
              OOOO
           OOOOOOOXX
        OOOOOOOOXXOOO
      OOOOOOOOXXOOOOOO
    OOOOOOOOXXOOOOOOIII
  OOOOOOOOXXOOOOOOIIIOOO
 OOOOOOOXXOOOOOOOIIIOOOOO
OOOOOOXXOOOOOOOIIIOOOOOOOO
  OOXXOOOOOOOIIIOOOOOOOOOOO
     OOOOOOIIIOOOOOOOOOOOOOO
        OIIIOOOOOOOOOOOOOOOOO
            OOOOOOOOOOOOOOOOOO
                OOOOOOOOOOOOOOY
                     OOOOOOOYYYY
                          YYYYYYY
                               YYY


I tried to make it look like a piece of cake, but it's not that easy... xD

Has anybody an idea of what else could be done to make a "stinkbomb" ? :p
Last edited on
closed account (z05DSL3A)
_____
_..--'''@ @'''--.._
.' @ @ '.
( @ /----------^-)
|'._ @ //|###########|
|~ ''--..@|',|}}}}}}}}}}}|
| ~ ~ |/ |###########|
| ~~ ~ ~|./|{{{{{{{{{{{|
'._ ~ ~ ~ |,/`````````````
''--.~.|/


Here you go:

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
#include <iostream>

using namespace std;
int main() 
{
    int count = 0;
    int CHAR = 72;
LOOP:
    if(count == 12) goto END;
    else printf("%c",CHAR);
    switch(count)
    {
        case 0: CHAR = CHAR+29; break;
        case 1: CHAR = CHAR+7; break;
        case 2: break;
        case 3: CHAR = CHAR+3; break;
        case 4: CHAR = CHAR-79; break;
        case 5: CHAR = CHAR+55; break;
        case 6: CHAR = CHAR+24; break;
        case 7: CHAR = CHAR+3; break;
        case 8: CHAR = CHAR-6; break;
        case 9: CHAR = CHAR-8; break;
        case 10: CHAR = CHAR-67; break;
    }
    count=count+1;
    goto LOOP;
END:
    return 0;
}
Last edited on
Really nice cake! Can I eat it ?
And another crappy program :D (or "how to spend time on stupid things" xD)
Topic archived. No new replies allowed.