28700 ui
#include <stdio.h> #define N 10 struct student_message{ char name[30]; double qimo; double banji; char student_cadre; char student_west; unsigned int paper_number; }; struct student { unsigned char student_num; struct student_message student_m[N]; }; struct student Student_burse={ 4, { {"YaoLin", 87, 82, 'Y', 'N', 0}, {"ChenRuiyi", 88, 78, 'N', 'Y', 1}, {"LiXin", 92, 88, 'N', 'N', 0}, {"ZhangQin", 83, 87, 'Y', 'N', 1} } }; void scholarship(struct student *src) { struct student *pInput; pInput = src; int i,j,k,max = 0; j = pInput->student_num; long burse_count = 0; int burse[5] = {0}; int buf[j]; // memset(burse,0,sizeof(burse)); // for(k=0; k<5; k++) { burse[k] = 0; } for(i=0; i<pInput->student_num; i++) { if((pInput->student_m[i].qimo > 80) && (pInput->student_m[i].paper_number >= 1)) burse[0] = 8000; if((pInput->student_m[i].qimo > 85) && (pInput->student_m[i].banji > 80)) burse[1] = 4000; if(pInput->student_m[i].qimo > 90) burse[2] = 2000; if((pInput->student_m[i].qimo > 85) && (pInput->student_m[i].student_west == 'Y')) burse[3] = 1000; if((pInput->student_m[i].student_cadre == 'Y') && (pInput->student_m[i].banji > 80)) burse[4] = 850; buf[i] = burse[0] +burse[1]+burse[2]+burse[3]+burse[4]; //memset(burse,0,sizeof(burse)); for(k=0; k<5; k++) { burse[k] = 0; } //burse_count += buf[i]; //printf("%d\t",buf[i]); } for(k=0; k<pInput->student_num; k++) { // printf("%d", buf[k]); if(buf[max] < buf[k]) max = k; burse_count +=buf[k]; } //bubblesort(buf,j); printf("%s\n",pInput->student_m[max].name); printf("%d\n",buf[max]); printf("%d\n",burse_count); } int main(void) { struct student *src; src = &Student_burse; printf("Simple input\n"); printf("4\n"); printf("YaoLin 87 82 Y N 0\n"); printf("ChenRuiyi 88 78 N Y 1\n"); printf("LiXin 92 88 N N 0\n"); printf("ZhangQin 83 87 Y N 1\n"); printf("\n"); printf("output\n"); scholarship(src); return 0; }