zoukankan      html  css  js  c++  java
  • UCF Local Programming Contest 2016 2020.3.28

     A. Majestic 10

    The movie "Magnificent 7" has become a western classic. Well, this year we have 10 coaches training the UCF programming teams and once you meet them, you’ll realize why they are called the "Majestic 10"! The number 10 is actually special in many different ways. For example, in basketball, they keep track of various statistics (points scored, rebounds, etc.) and if a player has 10+ (10 or more) in a particular stat, they call it a double.

    The Problem:

    Given three stats for a basketball player, you are to determine how many doubles the player has, i.e., how many of the stats are greater than or equal to 10. 

    The Input: 

    The first input line contains a positive integer, n, indicating the number of players. Each of the following n input lines contains three integers (separated by a space and each between 0 and 100, inclusive), providing the three stats for a player. 

    The Output: 

    Print each input line as it appears in the input. Then, on the following output line, print a message indicating how many stats are greater than or equal to 10: 

        print zilch if none of the three stats is greater than or equal to 10, 

        print double if one of the three stats is greater than or equal to 10, 

        print double-double if two of the three stats are greater than or equal to 10,

        print triple-double if all three stats are greater than or equal to 10. 

    Leave a blank line after the output for each player. 

    样例输入

    4 
    5 0 8 
    30 10 50 
    20 5 20 
    5 100 6

    样例输出

    5 0 8 
    zilch
    
    30 10 50 
    triple-double 
    
    20 5 20 
    double-double 
    
    5 100 6 
    double
    题解:这题思路比较简单,就是直接判断这3个数字有几个超过10的数字,没有超过输出zilch,一个超过输出double,然后double-double triple-double,用if一个一个判断就好
    直接看代码:
    #include<iostream>
    using namespace std;
    int main(){
    	int n,a[1001],sum;
    	cin>>n;
    	while(n--){
    		sum=0;
    		for(int i=0;i<3;i++){
    			cin>>a[i];
    			if(a[i]>=10){
    				sum++;
    			}
    		}
    		for(int i=0;i<2;i++){
    			cout<<a[i]<<" ";
    		}
    		cout<<a[2]<<endl;
    		if(sum==0){
    			cout<<"zilch"<<endl;
    		}
    		if(sum==1){
    			cout<<"double"<<endl;
    		}
    		if(sum==2){
    			cout<<"double-double"<<endl;
    		}
    		if(sum==3){
    			cout<<"triple-double"<<endl;
    		}
    		if(n!=0){
    			cout<<endl;
    		}
    	}
    } 
    
    
     
  • 相关阅读:
    基于Redis的短链接设计思路
    再谈对协变和逆变的理解(Updated)
    Java基础—ClassLoader的理解
    遇到个小问题,Java泛型真的是鸡肋吗?
    一次失败升级后的反思
    JVM是如何分配和回收内存?有实例!
    一个Java对象到底占用多大内存?
    《深入理解Java虚拟机》读书笔记:垃圾收集器与内存分配策略
    快速掌握RabbitMQ(二)——四种Exchange介绍及代码演示
    快速掌握RabbitMQ(一)——RabbitMQ的基本概念、安装和C#驱动
  • 原文地址:https://www.cnblogs.com/liyongqi/p/12591775.html
Copyright © 2011-2022 走看看