题目链接:1038 统计同成绩学生 (20 point(s))

题目描述

本题要求读入 N 名学生的成绩,将获得某一给定分数的学生人数输出。

输入格式

输入在第 1 行给出不超过 10​5​​ 的正整数 N,即学生总人数。随后一行给出 N 名学生的百分制整数成绩,中间以空格分隔。最后一行给出要查询的分数个数 K(不超过 N 的正整数),随后是 K 个分数,中间以空格分隔。

输出格式

在一行中按查询顺序给出得分等于指定分数的学生人数,中间以空格分隔,但行末不得有多余空格。

输入样例

10
60 75 90 55 75 99 82 90 75 50
3 75 90 88

输出样例

3 2 0

C代码

/**********************************************************************************
Submit Time Status Score Problem Compiler Run Time User
8/6/2019, 12:46:53 Accepted 20 1038 C (gcc) 44 ms wowpH
**********************************************************************************/
#include<stdio.h>
int main() {
int n, k, score; // 人数,要查询的个数,成绩
scanf("%d", &n);
int number[101] = { 0 }; // 每个分数的人数为0
for (int i = 0; i < n; ++i) {
scanf("%d", &score);
++number[score]; // 分数为score的人数加1
}
scanf("%d", &k);
for (int i = 1; i < k; ++i) {
scanf("%d", &score);
printf("%d ", number[score]); // 输出分数为score的人数
}
scanf("%d", &score);
printf("%d", number[score]); // 最后一个
return 0;
}

提交结果

最新文章

  1. 代码高亮美化插件-----SyntaxHighlighter
  2. JavaScript 常用小功能
  3. Java——List集合
  4. git 添加远程仓库遇到的问题
  5. JAVA设计模式之模版方法模式
  6. 三、动态SQL语句
  7. C++设计模式——代理模式
  8. GuessNum
  9. PHP LINUX Notice: undefined $_GET完美解决方法
  10. printdir-deldir-bmp
  11. mysql timestamp 值不合法问题
  12. linux服务器在运行210天左右宕机
  13. linux Apache安装
  14. 团队作业4——第一次项目冲刺(ALpha版本)第四天
  15. Hadoop-Impala学习笔记之SQL参考
  16. 边框回归(Bounding Box Regression)详解
  17. FireFox(火狐)浏览器的相关问题
  18. python解释器配置和python常用快捷键
  19. Java中public、private、protect对数据成员或成员函数的访问限制
  20. CentOS 6.4 命令行 安装 VMware Tools

热门文章

  1. 记一次有惊无险的 JVM 优化经历
  2. JVM(一) ---JVM的数据模型
  3. html5中 input的pattern属性 和 details/summary元素
  4. html5中output元素详解
  5. CENTOS7安装OPENSSL
  6. Java逻辑分页代码
  7. org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
  8. Code Quality and Security | SonarQube
  9. Git - 高级合并
  10. 小D课堂 - 零基础入门SpringBoot2.X到实战_第7节 SpringBoot常用Starter介绍和整合模板引擎Freemaker、thymeleaf_28..SpringBoot Starter讲解