Advertisement
JosepRivaille

P51352: Elements

Feb 21st, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //Precondició: A guanya a P, P guanya a V i V guanya a A
  5. //Postcondició: Retorna el guanyador
  6.  
  7. int main() {
  8.   char p;
  9.   cin >> p;
  10.   if (p == 'A') {
  11.     cin >> p;
  12.     if (p == 'P') cout << 1 << endl;
  13.     else if (p == 'V') cout << 2 << endl;
  14.     else cout << '-' << endl;
  15.   }else if (p == 'P') {
  16.     cin >> p;
  17.     if (p == 'A') cout << 2 << endl;
  18.     else if (p == 'V') cout << 1 << endl;
  19.     else cout << '-' << endl;
  20.   }else {
  21.     cin >> p;
  22.     if (p == 'P') cout << 2 << endl;
  23.     else if (p == 'A') cout << 1 << endl;
  24.     else cout << '-' << endl;
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement