llvlleo1810

Phân loại các kí tự trong chuỗi

Jul 29th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<ctype.h>
  4.  
  5. int main(){
  6.     char s[500];
  7.     gets(s);
  8.     int count1=0,count2=0,count3=0;
  9.     for(int i=0;i<strlen(s);i++){
  10.         if(isalpha(s[i])) count1++;
  11.         else if(isdigit(s[i])) count2++;
  12.         else count3++;
  13.     }
  14.     printf("%d %d %d",count1,count2,count3);
  15. }
Add Comment
Please, Sign In to add comment