x2311

Untitled

May 2nd, 2022
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4.  
  5.  
  6. const int SIZE = 5;
  7. using namespace std;
  8.  
  9. int main() {
  10.     ifstream file;
  11.     file.open("..\\tess.txt");
  12.     //error checking
  13.     if (!file.is_open()) {
  14.         cout << "ERROR\n\n";
  15.         return 1;
  16.     }
  17.     int i;
  18.     vector<int> s;
  19.     int k = 0;
  20.     for (file >> i; !file.eof(); file >> i) {
  21.         if (k < SIZE) {
  22.             s.push_back(i);
  23.             cout << s[k] << " ";
  24.             k++;
  25.         }
  26.     }
  27.     for (int j = 0; j < SIZE; ++j) {
  28.         if(j==0 || j==1){
  29.             continue;
  30.         }
  31.         if(s[j-1]== s[j-2]){
  32.             cout << "\nrez: " << j;
  33.             break;
  34.         }
  35.     }
  36.     file.close();
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment