Eddie_1337

1 atestat

Oct 9th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. bool verif_cif(int x) {
  7.     while (x != 0) {
  8.         if (x % 2 == 0)
  9.             x /= 10;
  10.         else
  11.             return false;
  12.     }
  13.     return true;
  14. }
  15. int main() {
  16.     int n, v[1000], max, x;
  17.     ifstream f1("numere.in");
  18.     ofstream f2("numere.out");
  19.     f1 >> n;
  20.     for (int i = 1; i <= n; i++)
  21.         f1 >> v[i];
  22.     max = v[1];
  23.     for (int i = 1; i <= n; i++) {
  24.         x = v[i];
  25.         if (verif_cif(x) == 1) {
  26.             f2 << v[i] << ' ';
  27.             if (max < v[i])
  28.                 max = v[i];
  29.         }
  30.     }
  31.     f2 << endl;
  32.     f2 << max;
  33.     f1.close();
  34.     f2.close();
  35.     system("pause");
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment