Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include<iostream>
  2. #include <sstream>
  3. #include <algorithm>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. unsigned int getMinDigitAtNaturalNumber(const unsigned int natural_number)
  8. {
  9.     unsigned int min_digit = natural_number % 10;
  10.     int cutted_number = natural_number / 10;
  11.     while(cutted_number != 0)
  12.     {
  13.         if((cutted_number % 10) < min_digit)
  14.         {
  15.             min_digit = cutted_number % 10;
  16.         }
  17.         cutted_number /= 10;
  18.     }
  19.    
  20.     return min_digit;
  21. }
  22.  
  23. int main() {
  24.  
  25.     unsigned int natural_number = 0;
  26.     cin >> natural_number;
  27.      vector <int> mas;
  28.     int c = 0;
  29.    
  30.     int size = sizeof(mas)/sizeof(mas[0]);
  31.    
  32.     int b = getMinDigitAtNaturalNumber(natural_number);
  33.     for(int i=0;natural_number!=0;i++)
  34.        {mas.push_back(natural_number%10); natural_number/=10; c++;};
  35.        
  36.        int count = 0;
  37.        
  38.     for(int i=c-1;i>=0;i--)
  39.     if(mas[i] == b && count < 1)
  40.     {
  41.         count++;
  42.     }
  43.     else {
  44.     cout<<mas[i];  
  45.     }
  46.            
  47.        
  48.        
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement