codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; void intro(); void loopsatsen_random(); void refresh(); void namn(); void ifsats1(); void ifsats2(); void ifsats3(); void ifsats4(); void ifsats5(); int Antal_Omg = 1; int Summan; int Summan1; int o[5]; int a[5]; int x[6]; int temp; int z[5]; char ja_eller_nej; char fort_till_spel; string namn1; void namn() { cout << "Innan vi b\x94rjar, var v\x84nlig att skriva in ditt f\x94rnamn: "; cin >> namn1; system ("cls"); } void intro() { cout << "V\x84lkommen " << namn1 << " till MasterMind, ett projekt utvecklat utav Leon Boman" << endl << endl; cout << "Vill du l\x84ra dig reglerna innan spelet drar ig\x86ng? (y/n): "; // Tar reda på om spelaren vill veta reglerna cin >> ja_eller_nej; if (ja_eller_nej == 'y'){ system("cls"); cout << "Regler!" << endl; cout << "I detta spel ska du lista ut de r\x84tta f\x84rgerna." << endl; cout << "Det finns fem olika f\x84rger att v\x84lja mellan:" << endl << endl << "R\x94" "d" << endl << "Bl\x86" << endl << "Gul" << endl << "Gr\x94n" << endl << "Brun" << endl << endl; cout << "Alla f\x84rger m\x86ste vara i exakt ordning innan du vunnit spelet." << endl; cout << "'0' markerar att du har valt r\x84tt f\x84rg fast i fel ordning." << endl; cout << "'1' markerar att du valt r\x84tt f\x84rg i r\x84tt ordning." << endl; cout << "'X' markerar att du valt helt fel f\x84rg." << endl << endl; cout << "Skriv in en valfri bokstav f\x94r att fors\x84tta till spelet!" << endl; cin >> fort_till_spel; if (fort_till_spel == 'a'){ cout << "Now guess!" << endl; } } else if (ja_eller_nej == 'n'){ } } void refresh() { system("cls"); cout << "Let's guess!" << endl << endl; cout << "1. Red" << endl << "2. Blue" << endl << "3. Yellow" << endl << "4. Green" << endl << "5. Brown" << endl << endl; } void ifsats1() { if (x[0] == z[0]){ cout << "1 "; } else if (x[1] == z[0]){ cout << "0 "; } else if (x[2] == z[0]){ cout << "0 "; } else if (x[3] == z[0]){ cout << "0 "; } else if (x[4] == z[0]){ cout << "0 "; } else{ cout << "X "; } } void ifsats2() { if (x[0] == z[1]){ cout << "0 "; } else if (x[1] == z[1]){ cout << "1 "; } else if (x[2] == z[1]){ cout << "0 "; } else if (x[3] == z[1]){ cout << "0 "; } else if (x[4] == z[1]){ cout << "0 "; } else{ cout << "X "; } } void ifsats3() { if (x[0] == z[2]){ cout << "1 "; } else if (x[1] == z[2]){ cout << "0 "; } else if (x[2] == z[2]){ cout << "1 "; } else if (x[3] == z[2]){ cout << "0 "; } else if (x[4] == z[2]){ cout << "0 "; } else{ cout << "X "; } } void ifsats4() { if (x[0] == z[3]){ cout << "0 "; } else if (x[1] == z[3]){ cout << "0 "; } else if (x[2] == z[3]){ cout << "0 "; } else if (x[3] == z[3]){ cout << "1 "; } else if (x[4] == z[3]){ cout << "0 "; } else{ cout << "X "; } } void ifsats5() { if (x[0] == z[4]){ cout << "0 "; } else if (x[1] == z[4]){ cout << "0 "; } else if (x[2] == z[4]){ cout << "0 "; } else if (x[3] == z[4]){ cout << "0 "; } else if (x[4] == z[4]){ cout << "1 "; } else{ cout << "X "; } } void loopsatsen_random() { //Slumpar ut värderna srand(time(NULL)); z[0] = rand() % 5 + 1; z[1] = rand() % 5 + 1; z[2] = rand() % 5 + 1; z[3] = rand() % 5 + 1; z[4] = rand() % 5 + 1; cout << z[0] << z[1] << z[2] << z[3] << z[4] << endl; system("pause"); while (Summan<=4){ cout << " Omg\x86ng " << Antal_Omg << endl; cout << "**********************************************************************" << endl << endl; cout << "1.st: "; cin >> x[0]; cout << "2.nd: "; cin >> x[1]; cout << "3.rd: "; cin >> x[2]; cout << "4.th: "; cin >> x[3]; cout << "5.th: "; cin >> x[4]; ifsats1(); ifsats2(); ifsats3(); ifsats4(); ifsats5(); Antal_Omg++; Summan = o[0] + o[1] + o[2] + o[3] + o[4]; } } int main() { namn(); intro(); refresh(); loopsatsen_random(); cout << "Du klarade spelet efter " << Antal_Omg << " f\x94rs\x94k."; return 0; }
Private
[
?
]
Run code
Submit