Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
60
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. using namespace std;
  4.  
  5. fstream in("bac.txt");
  6.  
  7. int V[50], i=1, n=0, k=0, p, comp[50];
  8. int m = 0, j = 0;
  9. bool stop=false;
  10. int main()
  11. {
  12.     while (!in.eof())
  13.     {
  14.         in >> V[i];
  15.         i++;
  16.         n++;
  17.     }
  18.     for (i = 1; i <= n; i++)
  19.     {
  20.         if (V[i] % 2 != 0 && k < 3)
  21.         {
  22.             k++;
  23.         }
  24.         if (k==3 && stop == false)
  25.         {
  26.             stop = true;
  27.             p = i;
  28.         }
  29.     }
  30.     p++;
  31.     for (i = p; i <= n; i++)
  32.     {
  33.         if (V[i] % 2 == 0)
  34.         {
  35.             m++;
  36.             j++;
  37.             comp[j] = V[i];
  38.            
  39.         }
  40.         if(V[i]%2!=0)
  41.             i = 100;
  42.     }
  43.     if (comp[1] != NULL)
  44.     {
  45.         for (j = 1; j <= m; j++)
  46.         {
  47.             if (comp[j] > comp[j + 1])
  48.                 cout << comp[j] << " ";
  49.         }
  50.     }
  51.     else
  52.         cout << "NU";
  53.     cout << "\n";
  54.     system("PAUSE");
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement