eolymp
bolt
Try our new interface for solving problems
Problems

Maximum digit in a number

published at 4/8/24, 11:02:22 pm

include <iostream>

using namespace std; int main(){ long long n,q; cin>>n; int max=q%10; while(n!=0){ q=n%10; if(q>max){ max=q; } n=n/10; } cout<<max; return 0; }

published at 4/9/24, 6:36:01 am

include <iostream>

using namespace std; int main() { long long n,x[999999],i=0,max=-9999999,s; cin>>n; while(n!=0){ s=n%10; n/=10; x[i]=s; i++; } for(int j=0;j<i;j++){ if(x[j]>max){ max=x[j]; } } cout<<max;

return 0;

}