Advertisement
nguyenhappy92

Đếm một kư tự xuất hiện bao nhiêu lần trong chuỗi

Dec 19th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. // Dem ki tu xuat hien bao nhieu lan trong chuoi
  2. // Khai bao cac ham thu vien neu co
  3. //
  4. #include<stdio.h>
  5. #include<conio.h>
  6. #include<string.h>
  7. #define SIZE 100
  8. void main()
  9. {
  10. char S[SIZE];
  11. char b;
  12. gets(S);
  13. scanf("%c",&b);
  14. int n=strlen(S);
  15. int dem=0;
  16. for(int i=0;i<n-1;i++)
  17. {
  18. if(S[i]==b)
  19. dem++;
  20. }
  21. printf("%d",dem);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement