Advertisement
Eddie_1337

24 atestat

Feb 27th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. short int v[10];
  7.  
  8. int pn(int z) {
  9.     while (z >= 10)
  10.         z /= 10;
  11.     return z;
  12. }
  13.  
  14. int main() {
  15.     ifstream f("numere.in");
  16.     ofstream g("numere.out");
  17.     long long x;
  18.     int n, y, ok = 0;
  19.     f >> n >> x;
  20.     v[pn(x)]++;
  21.     for (int i = 2; i <= n; i++) {
  22.         y = x;
  23.         f >> x;
  24.         v[pn(x)]++;
  25.         if (y > x)
  26.             ok = 1;
  27.     }
  28.     if (!ok)
  29.         g << "DA" << endl;
  30.     else
  31.         g << "NU" << endl;
  32.     x = 0;
  33.     for(int i = 9; i >= 0; i--)
  34.         while (v[i]) {
  35.             x = x * 10 + i;
  36.             v[i]--;
  37.         }
  38.     g << x;
  39.  
  40.     f.close();
  41.     g.close();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement