int main(){ int tippzahl; srand(time(NULL)); cout<<"Das ist ein Wuerfelspiel\n"; cout<<"Auf welche zahl tippen sie ?\n"; cin>>tippzahl; if (tippzahl==1+rand()%6) //zahl von 1 bis 6 cout<<"Glückwunsch, die Zahl stimmt"; else cout<<"Leider falsch"; }
Das funktioniert mit einem Compiler, der ANSI C++ kompilieren kann. -- A! Elbereth Gilthoniel! silivren penna míriel o menel aglar elenath, Gilthoniel, A! Elbereth!