Advertisement
Dani_info

nr max cu cifrele unui nr

Feb 13th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n, p=0;
  7.     cout << "introdu numarul:" << endl;     cin >> n;
  8.     for (int i = 9; i >= 0; i--)
  9.     {
  10.         int v = n;
  11.         while (v > 0)
  12.         {
  13.             int c = v % 10;
  14.             v /= 10;
  15.             if (i == c)
  16.             {
  17.                 p = p * 10 + c;
  18.                 break;
  19.             }
  20.         }
  21.     }
  22.     cout <<p<<endl;
  23.     system("pause");
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement