0
Delete the greater number from a big number using just while loop
Input 5912 Output 512
12 Respuestas
+ 2
What if it takes more than 1 while-loop? does it have to be done with 1 while-loop?
What if there are multiple greatest digit? e.g. 2021 (digit 2 appear twice)
And what if all the digits are the same? e.g. 999
+ 2
I tried, but I couldn't get it to work as expected if I must strictly use only 1 while-loop ...
+ 1
Ipang agree with you but any idea?
+ 1
Ipang pang try with multiple while loop
+ 1
My confirmation remains unanswered ... what if there are multiple greatest digit? and what if all digits are the same?
+ 1
Here it uses 2 while loop. First one searches for largest digit, and second one builds the resulting number.
https://code.sololearn.com/ckC9l6ULuP9N/?ref=app
0
#include <iostream>
using namespace std;
int main()
{ int N,uc,c,y=0,p=1;
cin>>N;
;
while(N!=0){
uc=N%10;
if(max(uc,9))
c=uc*0;
N=N/10;
if(N%10!=0){
y=(N%10)*p+y;
p=p*10;
}
}
cout << y;
return 0;
}
0
this I try
0
Mirielle[ INACTIVE ] the program should see all numbers from that number and delete the biggest one
0
You have numbers till 9 so if you have a number like 9987 output will be 87
0
But is not specify the particulars cases