Bài 11. Tìm chữ số lớn nhất trong số nguyên có 3 chữ số. Ví dụ:
MAX.INP |
MAX.OUT |
486 |
8 |
Code tham khảo:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
freopen("MAX.INP","r",stdin);
freopen("MAX.OUT","w",stdout);
int n;
cin >> n;
int a = n % 10;
n /= 10;
int b = n % 10;
n /= 10;
int c = n;
int max = a;
if(max < b) max = b;
if(max < c) max = c;
cout << max;
return 0;
}