2012年北理工计算机学院保研C++上机复试题(一)
来源:互联网 发布:星河战队 知乎 编辑:程序博客网 时间:2024/05/17 06:24
输入:每个学生一行,先输入学号,接着是各科成绩(0~5),科目门次不定,中间用空格隔开。
输出:每个学生的平均分(一位小数)从大到小排列输出,挂科(分数<=2)2门以上的同学按门次从小到大输出。
样例:
Input:1, 4, 5, 4, 52, 53, 2, 2, 14, 2, 1, 3Output:平均分:2, 51, 4.54, 23, 1.7挂科:4, 23, 3
题目比较简单,用的方法也比较笨。
#include <string.h>#include <stdio.h>struct stu{ int num; double per; int fail;};int main(){ struct stu student[100]; int i,j,n1,n2,tt; double fen,t; char nouse; for (i=0;i<100;i++){ student[i].num = 0; student[i].per = 0; student[i].fail = 0; } for(i=0;;i++){ // 一共有i个学生 scanf("%c",&nouse); if (nouse == '\n'){ break; } else{ student[i].num = nouse-'0'; } scanf("%c",&nouse); for(j=0;;j++){ scanf("%lf%c",&fen,&nouse); student[i].per += fen; if (fen <= 2){ student[i].fail ++; } if (nouse == '\n'){ student[i].per = student[i].per/(j+1); break; } } } for(n1=0;n1<i;n1++){ for(n2=0;n2<i-n1-1;n2++){ if(student[n2].per<student[n2+1].per){ t = student[n2+1].per; student[n2+1].per = student[n2].per; student[n2].per = t; tt = student[n2+1].num; student[n2+1].num = student[n2].num; student[n2].num = tt; tt = student[n2+1].fail; student[n2+1].fail = student[n2].fail; student[n2].fail = tt; } } } printf("平均分:\n"); for(j=0;j<i;j++){ printf("%d %.1f\n",student[j].num,student[j].per); } for(n1=0;n1<i;n1++){ for(n2=0;n2<i-n1-1;n2++){ if(student[n2].fail>student[n2+1].fail){ t = student[n2+1].per; student[n2+1].per = student[n2].per; student[n2].per = t; tt = student[n2+1].num; student[n2+1].num = student[n2].num; student[n2].num = tt; tt = student[n2+1].fail; student[n2+1].fail = student[n2].fail; student[n2].fail = tt; } } } printf("挂科:\n"); for(j=0;j<i;j++){ if (student[j].fail != 0) printf("%d %d\n",student[j].num,student[j].fail); } return 0;}
- 2012年北理工计算机学院保研C++上机复试题(一)
- 北理工2011年计算机复试上机题(一)
- 北理工2012年计算机研究生复试上机题
- 北理工2011年计算机复试上机题(二)
- 北理工2011年计算机复试上机题(三)
- 浙江大学计算机学院2007年考研复试上机题
- 华中科技大学_2005保研___考研计算机_复试上机
- 华中科技大学_2006保研___考研计算机_复试上机
- 华中科技大学_2006保研___考研计算机_复试上机
- 华中科技大学_2008保研___考研计算机_复试上机
- 2010年北邮复试计算机学院上机测试题
- 【北理工研究生复试上机题】完数和盈数
- 【北理工研究生复试上机题】邮票面额问题
- 【北理工复试上机题】创建类判断是否是直角三角形
- 2011年北航计算机复试上机题
- 北航计算机复试上机题(2008)
- 北航计算机复试上机题(2009)
- 北京理工大学计算机学院2012年研究生复试面试题搜集
- ewf
- Android中xml设置Animation动画
- C++ String对象中字符的处理
- WinCE触摸屏驱动(开发详解)
- hdu2601 An easy problem
- 2012年北理工计算机学院保研C++上机复试题(一)
- http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=301 (矩阵的用法)
- Linux嵌入式 -- 内核 - 内存管理
- C++标准库vector类(简单用法记录)
- stl hashmap与map hashmap与hashtable
- C语言猴子算法(BOGO)
- 2013华为编程大赛成都第三组 求复数的平均值
- 用Keil-MDK开发TQ2440裸机程序入门教程——LED流水灯实现
- C语言文件操作