小白求助,球求大佬帮个忙,帮忙查个错
#include "stdio.h"#include "stdlib.h"
struct courses
{
int programming;
int database;
int network;
double score;
int level;
scanf("%lf",&score);
if (score>300||score<0) //300分如何计算及格分来评定等级 还有这个if结构不知道哪里错了
{
printf("成绩输入错误!\n");
}
else
{
level=(int)((score-180)/10);
switch(level)
{
case 1: printf("优\n");break;
case 2: printf("优\n");break;
case 3: printf("良\n");break;
case 4: printf("中\n");break;
case 5: printf("差\n");break;
default: printf("劣\n");break;
}
}
};
struct student
{
int num; //学号
char name[10]; //姓名
int sum; //总分
struct courses sc[3];
};
void sumScore(struct student students[])
{
int i;
for (i = 0; i < 3; i++)
{
students[i].sum=students[i].sc[0].programming+students[i].sc[1].network+students[i].sc[2].database;
}
}
int main()
{
struct student students[5];//3名同学
int i;
for (i = 0; i < 3; i++)
{
printf("num:");
scanf("%d",&students[i].num);
printf("name:");
scanf("%s",students[i].name);
printf("programming score:");
scanf("%d",&students[i].sc[0].programming);
printf("network score:");
scanf("%d",&students[i].sc[1].network);
printf("database score:");
scanf("%d",&students[i].sc[2].database);
}
sumScore(students);
printf("num\tname\tsum\n");
for (i = 0; i < 3; i++)
{
printf("%d\t%s\t%d\n",students[i].num,students[i].name,students[i].sum);
}
return 0;
}