Guest User

Untitled

a guest
Jan 24th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. /* Marcin Motylski                          */
  2. /* Data: 17.10.2011                         */
  3. /* Program obliczający wielkość wygranej */
  4.  
  5. #include "stdafx.h"
  6. #include <iostream>
  7. #include <math.h>
  8. #include <conio.h>
  9. #include <time.h>
  10. #include <Windows.h>
  11.  
  12. using namespace std;
  13.  
  14. int main() {
  15.  
  16.         // Zmienne
  17.             int p;
  18.             int q;
  19.             int x;
  20.  
  21.                 // Wejście <-----
  22.                
  23.                     cout << "Podaj piewsza liczbe:";
  24.                     cin >> p;
  25.  
  26.  
  27.                     cout << "Podaj druga liczbe:";
  28.                     cin >> q;  
  29.                
  30.                
  31.                        
  32.  
  33.                         // Obliczenia
  34.  
  35.                             if(p % 2 == 0 && q == 2 || q == 4 || q == 5)
  36.                                 x = 1;
  37.                             else if(p % 2 == 0 && q == 1 || q == 3 || q == 6)
  38.                                 x = 2;
  39.                             else if(p % 2 != 0 && q == 1 || q == 3 || q == 6) {
  40.                                 if(p==q)
  41.                                     x = 3;
  42.                                 else
  43.                                     x = 4;
  44.                             }
  45.                             else if(p % 2 != 0 && q == 2 || q == 4 || q == 5) {
  46.                                 if(p == 5 && q == 5)
  47.                                     x = 5;
  48.                                 else
  49.                                     x = 6;
  50.                             }
  51.                             else
  52.                                 x = 7;
  53.  
  54.  
  55.  
  56.                             switch(x)   {
  57.                                 case 1:{cout << "Twoja wygrana to: " << p+3*q;break;}
  58.                                 case 2:{cout << "Twoja wygrana to: " << 2*q;break;}
  59.                                 case 3:{cout << "Twoja wygrana to: " << 5*p+3;break;}
  60.                                 case 4:{cout << "Twoja wygrana to: " << 2*q+p;break;}
  61.                                 case 5:{cout << "Twoja wygrana to: " << min{p, q} + 4 + 5;break;}
  62.                                 case 6:{cout << "Twoja wygrana to: " << min{p, q} + 4;break;}
  63.                                 case 7:{cout << "Liczba musi miescic sie w zakresie <1, 6>";break;}
  64.                             }  
  65.  
  66.                            
  67.  
  68.     // Koniec
  69.  
  70.         do {
  71.         system("cls");
  72.         cout << "Powtorzyc ? (T/N)" << endl;           
  73.         } while(toupper(_getch()) == 'T');
  74.  
  75.         _getch();
  76.             return 0;
  77.  
  78.  
  79.  
  80. /*
  81.  
  82.  
  83.  
  84.  
  85. */
  86. }
Add Comment
Please, Sign In to add comment