Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. void task2() {
  2.    
  3.     int array1[5];
  4.     int array2[5];
  5.    
  6.     for (int i = 0; i < 5; i++) {
  7.         int element1;
  8.         std::cin >> element1;
  9.        
  10.         //bool element1_check = std::cin.fail();
  11.        
  12.         while (!(std::cin >> element1)) {
  13.             std::cin.clear();
  14.             std::cin.ignore(1000, '\n');
  15.             std::cout << "test - czyszczenie bufora - syntax error";
  16.             std::cin >> element1;            
  17.         }
  18.        
  19.         array1[i] = element1;
  20.     }
  21.    
  22.     for (int i = 0; i < 5; i++) {
  23.         int element2;
  24.         std::cin >> element2;
  25.        
  26.         while (!(std::cin >> element2)) {
  27.             std::cin.clear();
  28.             std::cin.ignore(1000, '\n');
  29.             std::cout << "test - czyszczenie bufora - syntax error";
  30.             std::cin >> element2;
  31.         }
  32.        
  33.         array2[i] = element2;
  34.     }
  35.    
  36.     std::sort (array1, array1 + 5);
  37.     std::sort (array2, array2 + 5);
  38.    
  39.     for (int i = 0; i < 5; i++) {
  40.         if (array1[i] != array2[i]) {
  41.             std::cout << "Different." << std::endl;
  42.             break;
  43.         }
  44.         else {
  45.             std::cout << "Equal." << std::endl;
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement