Th3NiKo

Odwracanie kartek

Apr 6th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int ile;
  8.     cin >> ile;
  9.  
  10.     for(int i = 0; i < ile; i++){
  11.         int n;
  12.         string a = "";
  13.         cin >> n;
  14.         for(int j = 0; j< n; j++){
  15.             char x;
  16.             cin >> x;
  17.             a += x;
  18.         }
  19.         string jeden(n, '0');
  20.         string dwa(n, '1');
  21.         string trzy(n, '0');
  22.         trzy[0] = '1';
  23.         string cztery(n, '1');
  24.         cztery[0] = '0';
  25.  
  26.         if(jeden == a){
  27.  
  28.             cout << "0" << endl;
  29.         } else if(dwa == a){
  30.             cout << "1" << endl;
  31.         } else if(trzy == a){
  32.             cout << "2" << endl;
  33.         } else if(cztery == a){
  34.             cout << "1" << endl;
  35.         } else {
  36.             cout << "NIGDY" << endl;
  37.         }
  38.  
  39.  
  40.  
  41.  
  42.     }
  43.  
  44.  
  45.  
  46.  
  47.     return 0;
  48. }
Add Comment
Please, Sign In to add comment