Laitofai

Untitled

Nov 16th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. //#30
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void fillArray(int *massiv, int razmer)
  7. {
  8.     for(int i = 0; i < razmer; i++){
  9.         cin >> massiv[i];
  10.     }
  11. }
  12.  
  13. bool isDifferent(int a)
  14. {
  15.     if(a / 10 == 0){
  16.         return false;
  17.     }
  18.     int arr[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  19.     while(a != 0){
  20.         arr[a % 10]++;
  21.         a /= 10;
  22.     }
  23.     for(int i = 0; i < 10; i++){
  24.         if(arr[i] > 1){
  25.             return false;
  26.         }
  27.     }
  28.     return true;
  29. }
  30.  
  31. int main()
  32. {
  33.     int n, m;
  34.     cin >> n >> m;
  35.     int X[n], Y[m];
  36.     fillArray(&X[0], n);
  37.     fillArray(&Y[0], m);
  38.     int cntOne = 0, cntTwo = 0;
  39.     for(int i = 0; i < n; i++){
  40.         if(isDifferent(X[i]) == true){
  41.             cntOne++;
  42.         }
  43.     }
  44.     for(int i = 0; i < m; i++){
  45.         if(isDifferent(Y[i]) == true){
  46.             cntTwo++;
  47.         }
  48.     }
  49.     if(cntOne > cntTwo){
  50.         cout << "X WIN!";
  51.     }
  52.     if(cntOne < cntTwo){
  53.         cout << "Y WIN!";
  54.     }
  55.     if(cntOne == cntTwo){
  56.         cout << "Draw >_<";
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment