Seal_of_approval

PrVecList1A

Jul 3rd, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <list>
  4.  
  5. using namespace std;
  6.  
  7. int main (void)
  8. {
  9.     ifstream in("input.txt");
  10.  
  11.     list <int> ls;
  12.     list <int>::iterator i;
  13.     int a;
  14.     bool b = true;
  15.     while (in >> a)
  16.     {
  17.         ls.push_back(a);
  18.     }
  19.  
  20.     for (i = ls.begin(); i != ls.end();)
  21.     {
  22.         a = *i;
  23.         if (a % 3 == 0)
  24.         {
  25.             i = ls.erase(i);
  26.             b = false;
  27.             break;
  28.         }
  29.         else i++;
  30.     }
  31.  
  32.     if (b == false)
  33.         for (i = ls.begin(); i != ls.end(); i++)
  34.             cout << *i << " ";
  35.     else cout << "No elem" << endl;
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment