Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- using namespace std;
- void NhapSoNguyenDuong(int &num)
- {
- do
- {
- cout << "\nEnter number: ";
- cin >> num;
- if ((num <= 1) || (num >= 10000000))
- cout << "\nMoi ban nhap lai";
- } while ((num <= 1) || (num >= 10000000));
- }
- int ChuSoLonNhat(int num)
- {
- int Max = num % 10;
- int phantu;
- while (num)
- {
- num /= 10;
- phantu = num % 10;
- if (phantu > Max)
- Max = phantu;
- }
- return Max;
- }
- int main()
- {
- int num;
- NhapSoNguyenDuong(num);
- cout << "So lon nhat trong chuoi so nhap vao la: " << ChuSoLonNhat(num) << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement