原 poj 2715(基础题) 奖学金
2012-04-10 09:10
197 查看
注意输出
练习sort 与 scanf
scanf会读入空格字符!!
练习sort 与 scanf
scanf会读入空格字符!!
#include <fstream> #include <string> #include <cstdio> #include <algorithm> using namespace std; #define _cdebbug //全局数据 struct scholar{ char stuname[30] ; int qimo ; int pingyi ; int essays ; char isganbu ; char iswest ; int money ; }; bool cmp(const scholar &a,const scholar &b) { return a.money < b.money; } int main() { //重定向 #ifdef _cdebbug freopen("F:\\input.txt","r",stdin ); #endif int n; int i,j ; int totalschalor = 0 ; scholar *pstu ; scanf("%d",&n) ; pstu = new scholar ; for (i = 0 ; i < n ; ++i) { scanf("%s",pstu[i].stuname) ; scanf("%d",&pstu[i].qimo) ; scanf("%d",&pstu[i].pingyi) ; scanf(" %c",&pstu[i].isganbu) ; scanf(" %c",&pstu[i].iswest) ; scanf("%d",&pstu[i].essays) ; pstu[i].money = 0; } for (i = 0 ; i < n ; ++i) { //院士 if ( (pstu[i].qimo>80) && (pstu[i].essays>=1) ) pstu[i].money += 8000 ; if ( (pstu[i].qimo>85) && (pstu[i].pingyi>80)) pstu[i].money += 4000 ; if (pstu[i].qimo > 90) pstu[i].money += 2000 ; if ( (pstu[i].qimo>85)&&(pstu[i].iswest=='Y')) pstu[i].money += 1000 ; if ((pstu[i].pingyi>80)&&(pstu[i].isganbu=='Y')) pstu[i].money += 850 ; totalschalor += pstu[i].money ; } stable_sort(pstu,pstu+n,cmp) ; int maxm = pstu[n-1].money ; for (i = 0 ; i < n ; ++i) { if (pstu[i].money == maxm) { printf("%s\n",pstu[i].stuname) ; printf("%d\n",pstu[i].money) ; break; } } printf("%d\n",totalschalor) ; //解除重定向关闭文件 #ifdef _cdebbug fclose(stdin); #endif return 0 ; }
相关文章推荐
- poj 百练 2715:谁拿了最多奖学金
- POJ 2715 谁拿了最多奖学金 解题报告
- POJ_1269_Intersecting_Lines_(计算几何基础)
- poj 1523 连通基础
- poj2524_并查集基础
- POJ 3264 线段树 基础入门
- POJ 基础数学
- POJ 1659 Frogs' Neighborhood(Havel_Hakimi定理,图论基础)
- POJ 1050 To the Max 暴力,基础知识 难度:0
- POJ 2524 宗教信仰 并查集 基础模板
- poj 3041 二分匹配 基础题(整理版:基础知识)匈牙利算法
- poj 百练2734(基础题)
- POJ 3616 Milking Time(基础DP)
- Poj 3246 Balanced Lineup(线段树基础)
- poj 1949 Chores(基础题)
- poj 1125 基础Floyd
- POJ 2777 线段树基础题
- poj 2135 (基础费用流)
- POJ 1611 并查集详解+基础应用
- POJ 3468 A Simple Problem with Integers 线段树区间更新 (值在基础上相加或相减)