Guest User

Untitled

a guest
Dec 11th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     setlocale(LC_ALL,"swedish");
  8.     int choice = 0, // Valet som spelaren kommer få.
  9.         fortune[8] = {1,1,1,1,1,1,1,1}, //"Kak"-arrayen
  10.         saved[8] = {}, //En array som sparar i vilken ordning allting kom.
  11.         wrong[8] = {}; // En array som sparar hur många gånger en kaka som redan ätits har valts.
  12.    
  13.     while(fortune[0,1,2,3,4,5,6,7] != 0)
  14.     {
  15.     for(int i = 0; i < 8; i++)
  16.     {
  17.         cout << "Vilken kaka vill du äta? ";
  18.         cin >> choice;  // Eftersom att val och array ska stämma får man göra choice-1
  19.         if(fortune[choice-1] == 0)
  20.         {
  21.             wrong[choice-1]++;
  22.             cout << "Tyvärr är kakan uppäten, du har redan valt den "<< wrong[choice-1] <<" ggr."<< endl;
  23.         }
  24.         if(fortune[choice-1] == 1)
  25.         {
  26.             if(choice == 1)
  27.             {
  28.                 cout << "Det blir inte alltid som man vill." << endl;
  29.                 fortune[0] = 0;
  30.                 saved[choice-1] = choice;
  31.             }
  32.             if(choice == 2)
  33.             {
  34.                 cout << "Imorgon blir det fint väder." << endl;
  35.                 fortune[1] = 0;
  36.                 saved[choice-1] = choice;
  37.             }
  38.             if(choice == 3)
  39.             {
  40.                 cout << "Kasta inte glas i stenhus." << endl;
  41.                 fortune[2] = 0;
  42.                 saved[choice-1] = choice;
  43.             }
  44.             if(choice == 4)
  45.             {
  46.                 cout << "Ät inte den gula snön." << endl;
  47.                 fortune[3] = 0;
  48.                 saved[choice-1] = choice;
  49.             }
  50.             if(choice == 5)
  51.             {
  52.                 cout << "Din bror är din pappas son." << endl;
  53.                 fortune[4] = 0;
  54.                 saved[choice-1] = choice;
  55.             }
  56.             if(choice == 6)
  57.             {
  58.                 cout << "Efter solsken kommer regn." << endl;
  59.                 fortune[5] = 0;
  60.                 saved[choice-1] = choice;
  61.             }
  62.             if(choice == 7)
  63.             {
  64.                 cout << "Gå inte över ån efter vatten." << endl;
  65.                 fortune[6] = 0;
  66.                 saved[choice-1] = choice;
  67.             }
  68.             if(choice == 8)
  69.             {
  70.                 cout << "Skjut inte björnen förrän skinnet är sålt." << endl;
  71.                 fortune[7] = 0;
  72.                 saved[choice-1] = choice;
  73.             }
  74.         }
  75.     }
  76.     }
  77.     system("CLS");
  78.     cout << "Du fick fraserna i följande ordning:" << endl;
  79.     for(int i = 0; i < 8; i++)
  80.     {
  81.         if(saved[i] == 1)
  82.         {
  83.             cout << "Det blir inte alltid som man vill." << endl;
  84.         }
  85.         if(saved[i] == 2)
  86.         {
  87.             cout << "Imorgon blir det fint väder." << endl;
  88.         }
  89.         if(saved[i] == 3)
  90.         {
  91.             cout << "Kasta inte glas i stenhus." << endl;
  92.         }
  93.         if(saved[i] == 4)
  94.         {
  95.             cout << "Ät inte den gula snön." << endl;
  96.         }
  97.         if(saved[i] == 5)
  98.         {
  99.             cout << "Din bror är din pappas son." << endl;
  100.         }
  101.         if(saved[i] == 6)
  102.         {
  103.             cout << "Efter solsken kommer regn." << endl;
  104.         }
  105.         if(saved[i] == 7)
  106.         {
  107.             cout << "Gå inte över ån efter vatten." << endl;
  108.         }
  109.         if(saved[i] == 8)
  110.         {
  111.             cout << "Skjut inte björnen förrän skinnet är sålt." << endl;
  112.         }
  113.     }
  114.     cout << endl;
  115.  
  116. system("pause");
  117. return 0;
  118. }
Add Comment
Please, Sign In to add comment