Advertisement
kokokozhina

text_I_10

Dec 28th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. //дан текстовый файл, напечатать все нечетные строки
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream in("in.txt");
  10.  
  11.     string s;
  12.     int i = 1;
  13.     while(in.peek() != EOF)
  14.     {
  15.         getline(in, s);
  16.         if (i % 2)
  17.             cout << s << endl;
  18.         i++;
  19.     }
  20.  
  21.     system("pause");
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement