Advertisement
nguyenhappy92

Cho số nguyên dương n, hãy tìm chữ số đầu tiên của n

Oct 6th, 2015
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. // Cho so nguyen duong n, hay tim chu so dau tien cua n
  2. // VD: 6528 -> kq =6
  3.  
  4. // Khai bao thu vien
  5. #include<stdio.h>
  6. #include<conio.h>
  7.  
  8. void main()
  9. {
  10. int n;
  11. scanf("%d",&n);
  12. int dau;
  13. while (n!=0)
  14. {
  15. dau=n%10;
  16. n=n/10;
  17. }
  18. printf("%d",dau);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement