Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- const int SIZE = 5;
- using namespace std;
- int main() {
- ifstream file;
- file.open("..\\tess.txt");
- //error checking
- if (!file.is_open()) {
- cout << "ERROR\n\n";
- return 1;
- }
- int i;
- vector<int> s;
- int k = 0;
- for (file >> i; !file.eof(); file >> i) {
- if (k < SIZE) {
- s.push_back(i);
- cout << s[k] << " ";
- k++;
- }
- }
- for (int j = 0; j < SIZE; ++j) {
- if(j==0 || j==1){
- continue;
- }
- if(s[j-1]== s[j-2]){
- cout << "\nrez: " << j;
- break;
- }
- }
- file.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment