Suche ein möglichst übles / umständliches Hello World Programm
-
Der Titel sagt schon fast alles
Ich suche möglichst umständlichen Hello World Code (4 Seiten für "Hello World")
-
Einmal in
C
#include <iostream.h> //cout #include <stdlib.h> //atoi #define usageString "Usage:\n" void PrintHello(ostream &os=cout); void PrintEnvironment(char **); int main(int argc, char *argv[], char *envp[]) { int i, numberOfHellos = (argv[1] != 0 ? atoi(argv[1]) : 0); while (!numberOfHellos) { cout << usageString; cout << argv[0] << " numberOfHellos" << endl; cout << "\nEnter number of hellos: "; cin >> numberOfHellos; } for (i=0; i < numberOfHellos; i++){ int j; for (j=0; j<i; j++){ cout << " "; } PrintHello(); //cout << "\na second PrintHello on cerr\n"; //PrintHello(cerr); } for (i=0; i < numberOfHellos; i++){ int j; for (j = numberOfHellos; j > i; j--){ cout << " "; } cout << "hello world! " << endl; } PrintEnvironment(envp); return 0; }; void PrintHello(ostream &os) { os << "hello world! " << endl; } void PrintEnvironment(char **envp) { int i = 0; while (envp[i] != `\0') { cout << endl << "envp[" << i << "] = " << envp[i]; i++; } }
Einmal in
C++
// sample class hello #include "../object/object.h" class Hello : public Object { private: int number; public: Hello(int numberOfHellosToPrint); ~Hello(); //destructor of object is virtual void PrintHellos(); }; hello.c #include <iostream.h> #include "hello.h" Hello::Hello(int no) : Object(sizeof(this)) { number= no; } Hello::~Hello() { } void Hello::PrintHellos() { cout << "\nPrinting " << number << " `Hellos"'; for (int i=0; i < number; i++) { cout << "\n"; for (int j=0; j < i; j++) { cout << " "; } cout << "hello"; } } main.cc: //test of class hello Hello *helloPointer = new Hello(atoi(argv[1])); Hello helloStatic(7); helloStatic.PrintHellos(); helloPointer->PrintHellos(); ... delete helloPointer;
Die Quelle ist: C++ Praktikum von Siegfried Reich
Und noch was ähnliches: Nämlich den "Hello World"-Quellcode in 200 verschiedenen Programmiersprachen.
-
Schon nicht schlecht aber geht es evtl. noch dreckiger?
Shade of Mine hatte so was mal für C++ gepostet, da war wirklich eine DinA4 Seite dichtgeschrieben (keine Leerzeichen!) und am Ende kam nur Hello World raus.
Sowas für C wäre ideal
-
@NewProggie:
das ist beides C++@Topic:
mir fällt da spontan der IOCCC ein: http://remus.rutgers.edu/~rhoads/Obfuscated_C/hello_world.coder auch:
/* * HELLO WORLD program * by Jack Applin and Robert Heckendorn, 1985 * (Note: depends on being able to modify elements of argv[], * which is not guaranteed by ANSI and often not possible.) */ main(v,c)char**c;for(v[c++]="Hello, world!\n)"; (!!c)[*c]&&(v--||--c&&execlp(*c,*c,c[!!c]+!!c,!c)); **c=!c)write(!!*c,*c,!!**c);}
was mir persönlich sogar besser gefällt
-
Das ist schon gut, es muss sich nur noch compilieren lassen
-
da fehlt eine { vor dem for
segfaultet bei mir aber nur
-
Wie wärs damit?
#include <iostream> #include <string> class brainfuck_interpreter { protected: int i; char arr[30000]; std::string code; void ip(std::string const &part) { std::string part_of_part = ""; for(std::string::const_iterator itr = part.begin(); itr != part.end(); ++itr) { switch(*itr) { case '>': ++i; break; case '<': --i; break; case '+': ++arr[i]; break; case '-': --arr[i]; break; case '.': std::cout.put(arr[i]); break; case ',': arr[i] = std::cin.get(); break; case '[': while (*++itr != ']') { part_of_part += *itr; } while(arr[i]) ip(part_of_part); break; default: throw(*itr); } } } public: brainfuck_interpreter(std::string const &s) : code(s), i(0), arr() { for(int i = 0; i < 30000; ++i) arr[i] = 0; } void start() { ip(code); } }; int main() { std::string s = ">+++++++++[<++++++++>-]<.>++++++[<++>-]<-.+++++++..+++." ">>+++++++[<+++++>-]<+++++++++.------------." "<------------------------.++++++++++++++++++++++++." "+++.------.--------.>+.>++++++++++."; brainfuck_interpreter(s).start(); }
-
Wie wärs mit GNU Hello World?
-
0xdeadbeef schrieb:
Wie wärs damit?
...snip...Au ja, Brainfuck ist was cooles. Eines meiner Lieblinge:
http://esoteric.sange.fi/brainfuck/bf-source/prog/hanoi.bf
Allerdings musst da fuer C++ den interpreter mitliefern und dann siehts schon nicht mehr so cool aus. http://www.muppetlabs.com/~breadbox/bf/ da gibts Infos zur Programmiersprache mit der wohl kleinsten Menge an Grundfunktionen.Hier gabs mal nen "Worst-Hello-World"-Wettbewerb
http://www.gamedev.net/community/forums/topic.asp?topic_id=310918&PageSize=25&WhichPage=1
-
Bashar schrieb:
Wie wärs mit GNU Hello World?
Hehe, daran dachte ich auch als erstes
-
Hast du mal im Visual Studio das Beispiel "Hallo Welt"-Programm gesehen?
Das ist so ziemlich die umfangreichste Hallo Welt Anwendung die ich je gesehen habe.
Guenther
-
Hey wie wärs mit einem hardcore asm hello world programm.oder noch besser ein hallo world programm in reinem maschinencode inclusive einem eigenen compiler u.linker fürs programm ich denke da werden einige seiten für den code draufgehen:-)