Advertisement
nguyenhappy92

Hãy đếm số lượng chữ số lớn nhất của số nguyên dương n

Oct 6th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. // Hay dem so luong chu so lon nhat cua so nguyen duong n
  2.  
  3. // Khai bao thu vien
  4. #include<stdio.h>
  5. #include<conio.h>
  6.  
  7. void main()
  8. {
  9. int n;
  10. scanf("%d",&n);
  11. int a;
  12. int max=0;
  13. int dem =0;
  14. while(n!=0)
  15. {
  16. a=n%10;
  17. if(a>max)
  18. {
  19. max=a;
  20. dem++;
  21. }
  22. n=n/10;
  23. }
  24. printf("%d",dem);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement