daily pastebin goal
9%
SHARE
TWEET

nr max cu cifrele unui nr

Dani_info Feb 13th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top