首页 > 代码库 > PAT 1083 List Grades
PAT 1083 List Grades
#include <cstdio>#include <cstdlib>using namespace std;class Stu { public: char name[12]; char id[12];};int main() { int N = 0; // because all the grades are distinct & grade in range of [0, 100] // use simplified bucket sort here Stu* stu[101] = {0}; int grade; scanf("%d", &N); for (int i=0; i<N; i++) { Stu* tmp = new Stu(); scanf("%s%s%d", tmp->name, tmp->id, &grade); stu[grade] = tmp; } int lo, hi; scanf("%d%d", &lo, &hi); if (lo > hi) { int tmp = lo; lo = hi; hi = tmp; } bool has = false; for (int i=hi; i>=lo; i--) { if (stu[i] == NULL) continue; has = true; printf("%s %s\n", stu[i]->name, stu[i]->id); } if (!has) { printf("NONE"); } return 0;}
完成每日任务,睡觉了可以!
PAT 1083 List Grades
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。