zju2005排名_结构体
来源:互联网 发布:dns 端口号 编辑:程序博客网 时间:2024/06/02 05:04
http://acm.hdu.edu.cn/showproblem.php?pid=1236
浙大计算机研究生复试上机考试-2005年
不要使用标记数组,while(x--)写的很巧妙
#include <stdio.h>#include <algorithm>#include <string.h>using namespace std;struct E{char no[30]; //准考证号 int score; //最终得分};E stu[1004];bool cmp(E A,E B){ if (A.score!=B.score) { return A.score>B.score; } else return strcmp(A.no,B.no)<0;}int main(){int n,m,g,i,k,x; //学生数n,考题数m,分数线g,解决题目数xint mark[15]; //保存题目对应分值1~10道题目while (scanf("%d",&n)&& n!=0){scanf("%d%d",&m,&g); //题目总数,分数线for (i=1;i<=m;i++){scanf("%d",&mark[i]); //依次输入m道题目对应的分值}for(i=1;i<=n;i++) //n个学生成绩具体信息录入 {int s=0; //得分scanf("%s%d",stu[i].no,&x); //编号no,做出题目数xwhile (x--) //做出x道,累加x次分数,巧妙地写法{scanf("%d",&k); s+=mark[k];}stu[i].score=s; //保存在stu[i].score中}sort(stu+1,stu+1+n,cmp); //学生1~n排序int ans=0; //ans保存过线人数for (i=1;i<=n;i++){if (stu[i].score>=g){ans++;}}printf("%d\n",ans);for (i=1;i<=n;i++){if (stu[i].score>=g){printf("%s %d\n",stu[i].no,stu[i].score);}}}return 0;}
- zju2005排名_结构体
- SDUT_2015寒假集训_结构体练习_G-最终排名
- zju2005畅通工程_九度66
- 九度oj 题目1014:排名 【ZJU2005机试题5】
- 最终排名 结构体
- hdu1236排名(结构体)
- hdoj 1236 排名 【结构体】
- 排名(sort结构体)
- 结构体B 最终排名
- HDU 2093 考试排名---结构体排序
- 九度1014 排名 结构体排序
- hdu2093考试排名(结构体)
- 九度1014排名(结构体)
- HDU 1236 排名 (排序+结构体)
- hdu 2093 考试排名(结构体排序)
- hdu1236 排名(结构体排序)
- hdoj1236排名(sort快排,结构体)
- 考试排名(结构体的运用)
- Prediction: By 2013, Html5 Will Rule Enterprise Mobility.
- android开发
- 递归求解kitty猫的基因编码
- 创建和运行长时间运行的工作流(一)
- 2013寒假练习 1054 Largest prime factor
- zju2005排名_结构体
- 勤学如初起之苗,不见其增,日有所长;辍学如磨刀之石,不见其损,日有所亏。
- Java Jar 命令
- 九度OJ 教程36 排序二叉树的建立与比较是否相同。
- Impala学习--Impala概述
- HTML中的列表和框架
- 给DataList分页有两个办法:1、自定义实现分页方法 2、用第三方控件(例如AspNetPager)
- 随笔,台湾香港大陆词汇差异
- 为什么不开发Linux游戏