26: count the number of four digits that meet the condition.

Source: Internet
Author: User

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 }


 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.