题目描述
写出一个程序,接受一个有字母和数字以及空格组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。
输入例子:
ABCDEF A
输出例子:
1
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
int count = 0;
int i;
char str[1024];
char c;
gets(str);
scanf("%c", &c);
for(i = 0; i < strlen(str); i++)
{
if(str[i] == c)
{
++count;
}
}
cout << count;
return 0;
}