Advertisement
Kaktusen

Kaktus_glosprogram

Oct 17th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void clean();
  8.  
  9. int main() {
  10.     ifstream glosor("glosor.txt");
  11.     int right = 0;
  12.     int wrong = 0;
  13.  
  14.     int i, i2;
  15.  
  16.     string svenska[32];
  17.     string other[32];
  18.     string answer[32];
  19.  
  20.     for(i = 0; i<30; i++) {
  21.         glosor >> svenska[i] >> other[i];
  22.     }
  23.  
  24.     clean();
  25.  
  26.     for(i2 = 0; i2<30; i2++) {
  27.         cout << svenska[i2] << " - ";
  28.         cin >> answer[i2];
  29.         cout << endl;
  30.  
  31.         if(answer[i2] == other[i2]) {
  32.             right++;
  33.         } else if(answer[i2] == "p") {
  34.             cout << "Right: " << right << endl
  35.             << "Wrong: " << wrong << endl;
  36.             i2--;
  37.         } else if(answer[i2] == "cls") {
  38.             clean();
  39.         } else if(answer[i2] == "exit") {
  40.             break;
  41.         }
  42.  
  43.         else {
  44.             wrong++;
  45.         }
  46.     }
  47.     cin.ignore();
  48.     clean();
  49.  
  50.     cout << "Right: " << right << endl
  51.     << "Wrong: " << wrong << endl;
  52.     cout << "Press >ENTER< too exit!";
  53.  
  54.     cin.get();
  55.     return 0;
  56. }
  57.  
  58. void clean() {
  59.     for(int x = 0; x<25; x++) {
  60.         cout << endl;
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement