• 26:统计满足条件的4位数个数


    26:统计满足条件的4位数个数

    总时间限制: 
    1000ms
     
    内存限制: 
    65536kB
    描述

    给定若干个四位数,求出其中满足以下条件的数的个数: 

    个位数上的数字减去千位数上的数字,再减去百位数上的数字, 再减去十位数上的数字的结果大于零。

    输入
    输入为两行,第一行为四位数的个数n,第二行为n个的四位数,数与数之间以一个空格分开。(n <= 100)
    输出
    输出为一行,包含一个整数,表示满足条件的四位数的个数。
    样例输入
    5
    1234 1349 6119 2123 5017
    样例输出
    3
    来源
    习题(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 }
  • 相关阅读:
    ios开发之--把秒转换为天时分秒
    网络爬虫的类型
    网络爬虫的组成
    为什么要学网络爬虫
    什么是网络爬虫
    Windows 下安装 Python3
    Linux 下安装 Python3
    HTTP 代理
    HTTP Cookies
    爬虫的基本原理
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/6480774.html
Copyright © 2020-2023  润新知