zoukankan      html  css  js  c++  java
  • 2019/2/3统计各成绩段的学生人数

    题目描述
    编写程序,输入一批学生的成绩,遇0或负数则输入结束,要求统计并输出优秀(大于85)、通过(60~84)和不及格(小于60)的学生人数。

    提示:

    我们可以用三个变量 a b c 来表示各个分数段的人数。

    int a, b c;

    a = b = c = 0;

    最后打印输出使用如下语句:

    printf(">=85:%d ", a);

    学生的成绩可以定义在整型变量 score

    int score;

    输入
    程序的框架如下:

    int score;
    
    scanf("%d", &score);
    
    while (score>0) {
    
    	if ()  ...;
    
    	if ()  ...;
    
    	if ()  ...;				
    
    	scanf("%d", &score);
    
    }
    
    printf(。。。);
    
    printf(。。。);
    

    样例输入
    88 71 68 70 59 81 91 42 66 77 83 0
    样例输出

    =85:2
    60-84:7
    <60:2

    #include<stdio.h>
    int main()
    {int a, b,c;
    a = b = c = 0;
    int score;
    scanf("%d", &score);
    	
    
    	while (score>0) {
            
    		if(score>=85)
            {
    		a++;}
    		else if(score>=60)
            {
    		b++;}
    		else  
    		{
    		c++;}				
    scanf("%d", &score);
    		
    
    	}
    
    	printf(">=85:%d
    ", a);
    
    	printf("60-84:%d
    ",b);
    	
    	printf("<60:%d
    ",c);
    	
    	
    	
    	return 0;
    	
    	
    }
    

    此题多组输入的方法应该被借鉴

  • 相关阅读:
    Java基本数据类型的包装类
    Java数据类型基础
    Xscan安装
    Notepad++配置HexEditor插件
    [WP]XCTF-re2-cpp-is-awesome
    [WP]XCTF-tt3441810
    [WP]XCTF-re1-100
    [WP]XCTF-Mysterious
    [WP]xctf-parallel-comparator-200
    [WP]XCTF-elrond32
  • 原文地址:https://www.cnblogs.com/Locking-Shonn/p/12569218.html
Copyright © 2011-2022 走看看