Advertisement
Alberts00

augst_md_zinivaimini.cpp

Apr 21st, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.59 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     srand ( time (0));
  9.     int sk1, sk2, darb, atzime=0;
  10.     double rez;
  11.        
  12.     for ( int i = 1; i <= 10; i++)
  13.               {sk1 = 1 + rand() % 9;
  14.               sk2 = 1 + rand() % 9;
  15.               darb = 1 + rand() % 4;
  16.              
  17.                    {if (darb == 1) {cout << sk1 << " + " << sk2 << "=?"<<endl;
  18.                    cout << "Ievadiet rezultatu"<<endl;
  19.                    cin >> rez;
  20.                    if (rez == sk1+sk2) {cout << "Pareizi!"<<endl;
  21.                    atzime=atzime+1;}
  22.                    else {cout << "Nepareizi"<<endl;}}
  23.                    
  24.                    
  25.                                        else if (darb == 2) {cout << sk1 << " - " << sk2 << "=?"<<endl;
  26.                                         cout << "Ievadiet rezultatu"<<endl;
  27.                                         cin >> rez;
  28.                                         if (rez == sk1-sk2) {cout << "Pareizi!"<<endl;
  29.                                         atzime=atzime+1;}
  30.                                         else {cout << "Nepareizi"<<endl;}}
  31.                                        
  32.                                        
  33.                                                    else if (darb == 3) {cout << sk1 << " * " << sk2 << "=?"<<endl;
  34.                                                    cout << "Ievadiet rezultatu"<<endl;
  35.                                                    cin >> rez;
  36.                                                    if (rez == sk1*sk2) {cout << "Pareizi!"<<endl;
  37.                                                     atzime=atzime+1;}
  38.                                                     else {cout << "Nepareizi"<<endl;}}
  39.                                                    
  40.                                                    
  41.                                                          else if (darb == 4) {cout << sk1 << " / " << sk2 << "=?"<<endl;
  42.                                                           cout << "Ievadiet rezultatu"<<endl;
  43.                                                           cin >> rez;
  44.                                                           if (rez == sk1/sk2) {cout << "Pareizi!"<<endl;
  45.                                                           atzime=atzime+1;}
  46.                                                           else {cout << "Nepareizi"<<endl;}}}}
  47.                                                          
  48.    
  49.     cout << "Tava atzime ir " << atzime<<endl;
  50.  
  51.    
  52.    
  53.    
  54.     system("PAUSE");
  55.     return EXIT_SUCCESS;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement