Advertisement
Dani_info

eliminare cifra c

Sep 25th, 2018
113
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. {
  7.     // eliminare cifra c
  8.     int n; cin>>n;
  9.     int  c; cin>>c;
  10.     int p=0;
  11.     int k=1;
  12.     while (n){
  13.  
  14.         if (n%10!=c){
  15.             p=p+(n%10)*k;
  16.             k*=10;
  17.         }
  18.         n/=10;
  19.     }
  20.     cout<<p;
  21.     return 0;
  22. }
  23. //846
  24. // 6 - p=6
  25. //p=6+80
Advertisement
RAW Paste Data Copied
Advertisement