#include<stdio.h>
#include<stdlib.h>
#define N 4
struct student
{
char xuehao;
char name;
int a;
int b;
int c;
int d;
double zongce;
}str[10];
double fun(int x, int y, int z, int v);
int main()
{
struct student temp;
int i, j, k = 0;
double jidian[10];
FILE* fp;
if ((fp = fopen("D:\\1.txt", "r")) == NULL)
{
printf("无法打开文件\n");
getchar();
exit(1);
}
for (i = 0; i < 10; i++)
{
fscanf(fp, "%s%s%d%d%d%d", &str[i].xuehao, &str[i].name, &str[i].a, &str[i].b, &str[i].c, &str[i].d);
jidian[i]=fun(str[i].a,str[i].b,str[i].c,str[i].d);
if (jidian[i]>5.99 && str[i].a > 60 && str[i].b > 60 && str[i].c > 60 && str[i].d > 60)
{
str[i].zongce = (jidian[i] * 5 + 50) * 0.75 + (N * 0.25);
k++;
}
}
for (i = 0; i < k - 1; i++)
{
for (j = 1; j < k - i; j++)
{
if (str[j].zongce < str[j + 1].zongce)
{
temp = str[j];
str[j] = str[j + 1];
str[j + 1] = temp;
}
}
}
printf("满足奖学金要求的名单\n");
printf("学号
姓名\n");
for (i = 0; i < k; i++)
{
printf("%s
%s
\n", str[i].xuehao, str[i].name);
}
printf("………………………………………………………………\n");
printf("一等奖学金:\n");
printf("学号
姓名\n");
for (i = 0; i < 1; i++)
{
printf("%s
%s
\n", str[i].xuehao, str[i].name);
}
printf("二等奖学金:\n");
printf("学号
姓名\n");
for (i = 1; i < 4; i++)
{
printf("%s
%s
\n", str[i].xuehao, str[i].name);
}
printf("三等奖学金:\n");
printf("学号
姓名\n");
for (i = 4; i < k; i++)
{
printf("%s
%s
\n", str[i].xuehao, str[i].name);
}
fclose(fp);
getchar();
return 0;
}
double fun(int x,int y,int z,int v)
{
double jidian1, jidian2, jidian3, jidian4, jidian;
if (x >= 60)
{
jidian1 = (x - 60) * 0.2 + 2;
}
else
{
jidian1 = 0;
}
if (y >= 60)
{
jidian2 = (y - 60) * 0.2 + 2;
}
else
{
jidian2 = 0;
}y
if (z >= 60)
{
jidian3 = (z - 60) * 0.2 + 2;
}
else
{
jidian3 = 0;
}
if (v >= 60)
{
jidian4 = (v - 60) * 0.2 + 2;
}
else
{
jidian4 = 0;
}
jidian = (jidian1 * 5 + jidian2 * 6 + jidian3 * 4 + jidian4 * 3) / 18;
return jidian;
}