Problem C of Contest 100000581
2019-08-03 02:32
141 查看
佛了佛了
这么半天找出来的错,
1、原来是结构的数组大小
给小了
我跪了,查了老半天以为是语法错误。。。
以后不要那么小气!大方给空间哦!
2、switch case 1
没有引号!!
~~代码晚安~~
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct student{ char num[10]; char name[10]; int score; }stu[100001]; bool cmp1(student a,student b){ return strcmp(a.num,b.num)<0; } bool cmp2(student a,student b){ if(strcmp(a.name,b.name)!=0) return strcmp(a.name,b.name)<0; else return strcmp(a.num,b.num)<0; } bool cmp3(student a,student b){ if(a.score !=b.score) return a.score<b.score; else return strcmp(a.num,b.num)<0; } /*bool cmp1(student a, student b) { return strcmp(a.num,b.num)< 0; } bool cmp2(student a, student b) { if (strcmp(a.name,b.name) !=0) return strcmp(a.name,b.name)<0; else return strcmp(a.num,b.num)< 0; } bool cmp3(student a, student b) { if (a.score != b. score) return a.score < b.score; else return strcmp(a.num,b.num)< 0; }*/ int main(){ int n,c; int k=1; while(scanf("%d %d\n",&n,&c),n){ for(int i=0;i<n;i++){ scanf("%s %s %d\n",stu[i].num,stu[i].name,&stu[i].score); } printf("Case %d:\n",k++); switch(c){ case 1: sort(stu,stu+n,cmp1); break; case 2: sort(stu,stu+n,cmp2); break; case 3: sort(stu,stu+n,cmp3); break; } for(int i=0;i<n;i++){ printf("%s %s %d\n",stu[i].num,stu[i].name,stu[i].score); } //k++; } return 0; }
相关文章推荐
- Problem D of Contest 100000581
- UPC_Shandong muti-university Contest Problem I——The war of 3Q
- 【循环节】【矩阵乘法】MIPT-2016 Pre-Finals Workshop, Taiwan NTU Contest, Sunday, March 27, 2016 Problem F. Fibonacci of Fibonacci
- The 5th Zhejiang Provincial Collegiate Programming Contest------ProblemK:Kinds of Fuwas
- The 9th Zhejiang Provincial Collegiate Programming Contest->Problem :K-Yet Another Story of Rock-pap
- The 9th Zhejiang Provincial Collegiate Programming Contest->Problem :K-Yet Another Story of Rock-pap
- The 9th Zhejiang Provincial Collegiate Programming Contest->Problem :K-Yet Another Story of Rock-pap
- The 2012 ACM-ICPC Asia Changchun Regional Contest(problem B)
- hdu4788 水题 Hard Disk Drive (2013 Asia Chengdu Regional Contest problem H)
- The 6th Zhejiang Provincial Collegiate Programming Contest->Problem I:A Stack or A Queue?
- hdu4786 Fibonacci Tree (2013 Asia Chengdu Regional Contest problem F)
- 欧拉项目 Problem 12 of What is the value of the first triangle number to have over five hundred divisors
- The 11th Zhejiang Provincial Collegiate Programming Contest->Problem A:A - Pokemon Master
- IIUC ONLINE CONTEST 2008 / UVa 11389 The Bus Driver Problem (贪心)
- The Ninth Hunan Collegiate Programming Contest (2013) Problem G
- 2017 Wuhan University Programming Contest 现场赛I: A simple math problem(矩阵快速幂)
- HDU 2256 Problem of Precision
- Problem 16 - What is the sum of the digits of the number 2^1000?
- 2017 Wuhan University Programming Contest 现场赛 I. A simple math problem(矩阵快速幂)
- zoj2818 Root of the Problem 简单数学 开方