1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> using namespace std; // Hàm chính. int main() { int n, i; do{ cout << "\n Nhap n = "; cin >> n; }while(n <0 && printf("\n Error: n >= 0")); int m = n; do{ i = n % 10; n = n / 10; }while(n != 0); cout << "\n Chu so dau tien cua " << m << " la: " << i << endl; system("pause"); return 0; } |
