Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int chuoi(char a[], char ch);
- int main ()
- {
- char a[100], c;
- int slxh;
- printf("Nhap mot chuoi: ");
- fgets(a,99,stdin);
- printf("Nhap ky tu: ");
- scanf("%c", &c);
- slxh=chuoi(a,c);
- printf("So lan xuat hien cua ky tu %c la: %d", c, slxh);
- return 0;
- }
- int chuoi(char *a, char ch)
- {
- int solanxuathien,dem=0, i;
- /* for (i=0;i<ch;i++){ */
- for (i=0; i < strlen(a); i++) {
- if (a[i] == ch){
- dem++;
- }
- }
- /* return solanxuathien; */
- return dem;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement