26: count the number of four digits that meet the condition.
26: count the number of four digits that meet the condition
- View
- Submit
- Statistics
- Question
Total time limit:1000 ms Memory limit:65536kBDescription
Given a number of four digits, find the number that meets the following conditions:
The number in a single digit minus the number in a thousand digits, then the number in a hundred digits, and then the number in a ten digit are greater than zero.
InputThe input is two rows. The first row is n in four digits, and the second row is n in four digits. The number and number are separated by a space. (N <= 100)OutputThe output is a row containing an integer, indicating the number of four digits that meet the condition.Sample Input
5
1234 1349 6119 2123 5017
Sample output
3
SourceExercise (5-7)
1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 using namespace std;
6 int main()
7 {
8 int n;
9 cin>>n;
10 int tot=0;
11 for(int i=1;i<=n;i++)
12 {
13 int a;
14 cin>>a;
15 if((a%10-((a/1000)%10)-((a/100)%10)-((a/10)%10))>0)
16 tot++;
17 }
18 cout<<tot;
19 return 0;
20 }