nicuvlad76

Untitled

Oct 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int readInt ()
  5. {
  6.     bool minus = false;
  7.     int raspuns = 0;
  8.     char c;
  9.     while (true)
  10.     {
  11.         c = getchar();
  12.         if (c == EOF) return 100001;
  13.         if (c == '-')
  14.         {
  15.             minus = true;
  16.             break;
  17.         }
  18.         if (c>='0' && c<='9')
  19.         {
  20.             raspuns = c-'0';
  21.             break;
  22.         }
  23.     }
  24.     while (true)
  25.     {
  26.         c = getchar();
  27.         if (c<'0' || c>'9') break;
  28.         raspuns = 10*raspuns + c-'0';
  29.     }
  30.     if (minus == true) return -raspuns;
  31.     return raspuns;
  32. }
  33. int main()
  34. {
  35.     freopen ("parsare.in", "r", stdin);
  36.     freopen ("parsare.out", "w", stdout);
  37.     int x, maxim = -100001;
  38.     while (true)
  39.     {
  40.         x = readInt();
  41.         if (x == 100001)
  42.         {
  43.             cout << maxim;
  44.             return 0;
  45.         }
  46.         maxim = max(maxim, x);
  47.     }
  48.     return 0;
  49. }
Add Comment
Please, Sign In to add comment