题目描述:
wyh学长十分钟爱数字‘7’,他想知道每一个数字中有多少个数字‘7’
输入描述:
输入第一行一个整数T(1<=T<=10)
接下来有T组测试数据,对于每组测试数据,输入一个整数n(1<=n<=10000000000)
输出描述:
对于每组测试数据,输出对应答案
输入:
2
1234567
123456
输出:
1
0
题意:
题目描述
题解:
直接算
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn = 10000 + 5;
char s[maxn];
int main(){
int t;
scanf("%d",&t);
while(t--){
scanf("%s",s);
int ans = 0;
int l = strlen(s);
for(int i = 0;i < l; i ++){
if(s[i] == '7') ans ++;
}
printf("%d\n",ans);
}
return 0;
}