标签:cti NPU ESS inpu clu color typedef ima amp
#include <stdio.h> #include <stdlib.h> const int N=5; typedef struct student { long no; char name[20]; int score; }STU; void input(STU s[], int n); int findMinlist(STU s[], STU t[], int n); void output(STU s[], int n); int main() { STU stu[N], minlist[N]; int count; printf("¼Èë%d¸öѧÉúÐÅÏ¢\n", N); input(stu, N); printf("\nͳ¼Æ×îµÍ·ÖÈËÊýºÍѧÉúÐÅÏ¢...\n"); count = findMinlist(stu, minlist, N); printf("\nÒ»¹²ÓÐ%d¸ö×îµÍ·Ö£¬ÐÅÏ¢ÈçÏÂ:\n", count); output(minlist, count); system("pause"); return 0; } void input(STU s[], int n) { int i; for(i=0; i<n; i++) scanf("%ld %s %d", &s[i].no, s[i].name, &s[i].score); } void output(STU s[], int n) { int i; for(i=0; i<n; i++) printf("%ld %s %d\n", s[i].no, s[i].name, s[i].score); } int findMinlist(STU s[], STU t[], int n) { int i,j,k=0; STU temp; for(i=0;i<n;i++) for(j=0;j<n-1-i;j++) if(s[j].score>s[j+1].score) { temp = s[j]; s[j] = s[j+1]; s[j+1] = temp; } for(i=0;i<n;i++) if(s[i].score==s[j+1].score) t[k++]=s[i]; return k; }
#include <stdio.h> #include <stdlib.h> #include <string.h> const int N = 10; typedef struct student { long int id; char name[20]; float objective; float subjective; float sum; char level[10]; }STU; void input(STU s[], int n); void output(STU s[], int n); void process(STU s[], int n); int main() { STU stu[N]; printf("¼Èë%d¸ö¿¼ÉúÐÅÏ¢: ×¼¿¼Ö¤ºÅ£¬ÐÕÃû£¬¿Í¹ÛÌâµÃ·Ö(<=40)£¬²Ù×÷ÌâµÃ·Ö(<=60)\n", N); input(stu, N); printf("\n¶Ô¿¼ÉúÐÅÏ¢½øÐд¦Àí: ¼ÆËã×Ü·Ö£¬È·¶¨µÈ¼¶\n"); process(stu, N); printf("\n´òÓ¡¿¼ÉúÍêÕûÐÅÏ¢: ×¼¿¼Ö¤ºÅ£¬ÐÕÃû£¬¿Í¹ÛÌâµÃ·Ö£¬²Ù×÷ÌâµÃ·Ö£¬×Ü·Ö£¬µÈ¼¶\n"); output(stu, N); system("pause"); return 0; } void input(STU s[], int n) { int i; for(i=0;i<n;i++) scanf("%ld %s %f %f",&s[i].id,&s[i].name,&s[i].objective,&s[i].subjective); } void output(STU s[], int n) { int i; for(i=0;i<n;i++) printf("%ld %s %f %f %f %s\n",s[i].id,s[i].name,s[i].objective,s[i].subjective,s[i].sum,s[i].level); } void process(STU s[], int n) { int i,j,k; STU temp; for(i=0;i<n;i++) s[i].sum=s[i].objective+s[i].subjective; for(k=0;k<n-1;k++){ for(j=0;j<n-1-k;j++) if(s[j].sum<s[j+1].sum) { temp = s[j]; s[j] = s[j+1]; s[j+1] = temp; } } for (i= 0; i < n; i++) { if (s[i].sum >= s[int (n* 0.1)].sum) strcpy(s[i].level, "ÓÅÐã"); if (s[i].sum < s[int(n * 0.1)].sum&& s[i].sum>= s[int(n * 0.5)].sum) strcpy(s[i].level, "ºÏ¸ñ"); else strcpy(s[i].level, "²»ºÏ¸ñ"); } }
标签:cti NPU ESS inpu clu color typedef ima amp
原文地址:https://www.cnblogs.com/rsndm/p/12079906.html