Kaktusen

Glosor

Oct 17th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void clean();
  8. void menu();
  9. void read();
  10.  
  11. int right;
  12. int wrong;
  13.  
  14. int main() {
  15.     ifstream glosor("glosor.txt");
  16.  
  17.     int i, i2;
  18.  
  19.     int right = 0;
  20.     int wrong = 0;
  21.  
  22.  
  23.     string svenska[32];
  24.     string other[32];
  25.     string answer[32];
  26.  
  27.     for(i = 0; i<30; i++) {
  28.         glosor >> svenska[i] >> other[i];
  29.     }
  30.  
  31.     clean();
  32.     menu();
  33.  
  34.     for(i2 = 0; i2<30; i2++) {
  35.         cout << svenska[i2] << " - ";
  36.         cin >> answer[i2];
  37.         cout << endl;
  38.  
  39.         if(answer[i2] == other[i2]) {
  40.             right++;
  41.         } else if(answer[i2] == "p") {
  42.             cout << "Right: " << right << endl
  43.             << "Wrong: " << wrong << endl;
  44.             i2--;
  45.         } else if(answer[i2] == "cls") {
  46.             clean();
  47.         } else if(answer[i2] == "exit") {
  48.             break;
  49.         }
  50.  
  51.         else {
  52.             wrong++;
  53.         }
  54.     }
  55.     cin.ignore();
  56.     clean();
  57.  
  58.     cout << "Right: " << right << endl
  59.     << "Wrong: " << wrong << endl;
  60.     cout << "Press >ENTER< too exit!";
  61.  
  62.     cin.get();
  63.     return 0;
  64. }
  65.  
  66. void clean() {
  67.     for(int x = 0; x<25; x++) {
  68.         cout << endl;
  69.     }
  70. }
  71.  
  72. void menu() {
  73.     int answer;
  74.  
  75.     while(true) {
  76.         cout << "1) Start" << endl
  77.         << "2) Highscores" << endl
  78.         << "4) Exit" << endl;
  79.  
  80.         cout << "Answer: ";
  81.         cin >> answer;
  82.  
  83.         if(answer == 4) {
  84.             exit(1);
  85.         } else if(answer == 1) {
  86.             clean();
  87.             break;
  88.         } else if(answer == 2) {
  89.             clean();
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment