Advertisement
Eddie_1337

3 atestat

Oct 23rd, 2017
119
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.  
  4. using namespace std;
  5.  
  6. void main() {
  7.     short int n, p;
  8.     int a, min, c1, c2;
  9.     bool x = false;
  10.     ifstream f("date.in");
  11.     ofstream g("date.out");
  12.     f >> n;
  13.     for (short int i = 1; i <= n; i++) {
  14.         f >> a;
  15.         if (i == 1) c1 = a;
  16.         if (i == 2) c2 = a;
  17.         if (a % 2 && !x) {
  18.             x = true;
  19.             min = a;
  20.             p = i;
  21.         }
  22.         if (x && a % 2 && a < min) {
  23.             min = a;
  24.             p = i;
  25.         }
  26.     }
  27.     g << min << ' ' << p << endl;
  28.     if (!c1 && !c2)
  29.         g << 0;
  30.     else
  31.         if (!c1 && c2)
  32.             g << c2;
  33.         else
  34.             if (c1 && !c2)
  35.                 g << c1;
  36.             else {
  37.                 while (c1 != c2) {
  38.                     if (c1 > c2)
  39.                         c1 -= c2;
  40.                     else
  41.                         c2 -= c1;
  42.                 }
  43.                 g << c1;
  44.             }
  45.     f.close();
  46.     g.close();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement