#include<iostream>
#include<string>
using namespace std;
int main()
{
string str = "";
char s;
int ans=0;
getline(cin, str);//读取一行,不能扔用cin,因为有空格
scanf("%c", &s);
//tolower(char):把字母字符转换成小写,非字母字符不做出处理。
//touppre(char)函数是把字符串都转化为大写字母
for (int i = 0; i < str.length(); ++i)
{
if ((str[i] >= 'a'&&str[i] <= 'z') || (str[i] >= 'A'&&str[i] <= 'Z') || (str[i] >= '0'&&str[i] <= '9')||(str[i]==' '))
{
if (tolower(str[i]) == tolower(s))
ans++;
}
else//输入有误
{
printf("Input error");
break;
}
}
printf("%d", ans);
return 0;
}
#include<string>
using namespace std;
int main()
{
string str = "";
char s;
int ans=0;
getline(cin, str);//读取一行,不能扔用cin,因为有空格
scanf("%c", &s);
//tolower(char):把字母字符转换成小写,非字母字符不做出处理。
//touppre(char)函数是把字符串都转化为大写字母
for (int i = 0; i < str.length(); ++i)
{
if ((str[i] >= 'a'&&str[i] <= 'z') || (str[i] >= 'A'&&str[i] <= 'Z') || (str[i] >= '0'&&str[i] <= '9')||(str[i]==' '))
{
if (tolower(str[i]) == tolower(s))
ans++;
}
else//输入有误
{
printf("Input error");
break;
}
}
printf("%d", ans);
return 0;
}