Advertisement
Guest User

Untitled

a guest
May 31st, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int chuoi(char a[], char ch);
  4.  
  5. int main ()
  6. {
  7. char a[100], c;
  8. int slxh;
  9. printf("Nhap mot chuoi: ");
  10. fgets(a,99,stdin);
  11.  
  12. printf("Nhap ky tu: ");
  13. scanf("%c", &c);
  14.  
  15. slxh=chuoi(a,c);
  16. printf("So lan xuat hien cua ky tu %c la: %d", c, slxh);
  17.  
  18. return 0;
  19. }
  20.  
  21. int chuoi(char *a, char ch)
  22. {
  23. int solanxuathien,dem=0, i;
  24.  
  25. /* for (i=0;i<ch;i++){ */
  26. for (i=0; i < strlen(a); i++) {
  27.  
  28. if (a[i] == ch){
  29. dem++;
  30. }
  31. }
  32. /* return solanxuathien; */
  33. return dem;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement