p.s.个人收录用
题目描述
提莫喜欢codeforces,因此他有一串仅有小写字母组成、长度为10的字符串s。
提莫想知道这串字符串中有几位字符是与字符串"codeforces"不同。例如,string s=“coolforsez”与“codeforces”有四位字符不相同。
帮助提莫找出字符串s与字符串"codeforces"的不同。请注意,不能对字符串 s 中的字符重新排序。
输入
第一行一个整数t表示测试组数,然后是t行字符串,每行仅由10个小写字母组成
输出
对于每个测试样例,输出一个整数,表示字符串s中有几位字符与字符串"codeforces"不同。
样例输入 Copy
5 coolforsez cadafurcie codeforces paiuforces forcescode
样例输出 Copy
4 5 0 4 9
代码
#include <stdio.h>
#include <string.h>
//爱情故事(Love Story)
int main()
{
int t;
scanf("%d", &t);
char temp[] = "codeforces";
while (t--)
{
char s[11] = { 0 };
scanf("%s", s);
int diff = 0;
for (int i = 0; i < 10; i++)
{
if (s[i] != temp[i])
diff++;
}
printf("%d\n", diff);
}
}