HDU 1084 What is Your Grade?

Source: Internet
Author: User

* * Topic: 1, according to the number of questions answered, determine the student's score, 2, answer the number of the same, according to the time of the answer, determine the student's score; 3, answer the same number of questions, only one person can get 95,85,75,65 scores, others can only for 90,80,70,60*   /# include <stdio.h>struct Student/* struct for storing input data */{int solved;  /* Number of problem solving */int located;  /* Student's position */int H, m, s;  /* Time spent */int consume;      Total time spent int SCO; /* Final Results */};void sort (Student * stu, int num) {for (int i = 0; i < num; i++)//Two extreme cases {if (stu[i].solved = 5) {Stu[i]. SCO = 100;  }if (stu[i].solved = = 0) {Stu[i].sco = 50; }}int min,j,k,m,flag;//correct 4 questions for (j = 0; j < Num; J + +) {if (stu[j].solved = = 4) {min = stu[j].consume;for (k = 0; k < num ; k++) {if (stu[k].solved = = 4) {if (min >= stu[k].consume) {min = Stu[k].consume;flag = stu[k].located;//printf ("----%d\n ", stu[k].located);}}} Break;}} min = 0; Maximum value clear 0 for (m = 0; m < num; m++) {if (stu[m].solved = = 4) {if (stu[m].located = = flag) {Stu[m].sco = 95;} Else{stu[m].sco = 90;}}} For the three questions correctly (j = 0; j < Num; J + +) {if (stu[j].solved = = 3) {min = stu[j].consume;for (k = 0; k < num; k++){if (stu[k].solved = = 3) {if (min >= stu[k].consume) {min = Stu[k].consume;flag = stu[k].located;}}} Break;}} min = 0; Maximum value clear 0 for (m = 0; m < num; m++) {if (stu[m].solved = = 3) {if (stu[m].located = = flag) {Stu[m].sco = 85;} Else{stu[m].sco = 80;}}} Correct for (j = 0; j < Num; J + +) {if (stu[j].solved = = 2) {min = stu[j].consume;for (k = 0; k < num; k++) {if (stu[k].solv ed = = 2) {if (min >= stu[k].consume) {min = Stu[k].consume;flag = stu[k].located;}}} Break;}} min = 0; Maximum value clear 0 for (m = 0; m < num; m++) {if (stu[m].solved = = 2) {if (stu[m].located = = flag) {Stu[m].sco = 75;} Else{stu[m].sco = 70;}}} The for (j = 0; j < Num; J + +) {if (stu[j].solved = = 1) {min = stu[j].consume;for (k = 0; k < num; k++) {if (stu[k].solv ed = = 1) {if (min >= stu[k].consume) {min = Stu[k].consume;flag = stu[k].located;}}} Break;}} min = 0; Maximum value clear 0 for (m = 0; m < num; m++) {if (stu[m].solved = = 1) {if (stu[m].located = = flag) {Stu[m].sco = 65;} Else{stu[m].sco = 60;}}} int main (void) {int num; Student Stu[100];while (scanf ("%d", &Amp;num)! = EOF) {GetChar (); Absorbs the carriage return character. if (num < 0) Break;int time = 0;for (int i = 0; i < num; i++) {scanf ("%d%d:%d:%d", &stu[i].solved, &stu[i].h,  &AMP;STU[I].M, &stu[i].s); stu[i].located = i; /* Record the position of the input */time = (Stu[i].h * 3600) + (STU[I].M *) + (STU[I].S); stu[i].consume = Duration;} Sort (stu, num); for (int j = 0; j < Num; J + +) {printf ("%d\n", Stu[j].sco);}} return 0;}

HDU 1084 What is Your Grade?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.