Advertisement
CosminVarlan

Untitled

Dec 12th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int fr[10] = {5,7,2,4,5,8,9,12,6,4};
  7. int fr2[10];
  8. int cif=-1;
  9. int main()
  10. {
  11.     for(int i=0; i<=9; i++) fr2[i]=fr[i];
  12.     for(int i=8; i>=2; i-=2)
  13.     if (fr[i]>1) {
  14.         cif = i;
  15.         fr[i]-=2;
  16.         break;
  17.     }
  18.     if (cif==-1) {cout << "nu mere"; return 0;};
  19.  
  20.     cout << cif;
  21.     for(int i=9; i>=0; i--)
  22.     {
  23.         while (fr[i]>=2)
  24.         {
  25.             fr[i]-=2;
  26.             cout << i;
  27.         }
  28.     }
  29.     for(int i=9; i>=0; i--)
  30.     {
  31.         if (fr[i]){
  32.             cout << i;
  33.             break;
  34.         }
  35.     }
  36.  
  37.     for(int i=0; i<=9; i++)
  38.     {
  39.         while (fr2[i]>=2)
  40.         {
  41.             fr2[i]-=2;
  42.             cout << i;
  43.         }
  44.     }
  45.     cout << cif;
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement