#include <stdio.h>
int main()
{
double a,aver,sum=0,result=0,c;
int b,i,num;
double sum_a=0,sum_c=0;
int count=0;
printf("请输入要录入学科的数目:");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
printf("请输入第%d门课的学分和分数:",i);
scanf("%lf %d",&a,&b);
if(b>=90&&b<=100)
c=4.0;
else if(b>=85&&b<90)
c=3.7;
else if(b>=82&&b<=84)
c=3.3;
else if(b>=78&&b<=81)
c=3.0;
else if(b>=75&&b<=77)
c=2.7;
else if(b>=71&&b<=74)
c=2.3;
else if(b>=66&&b<=70)
c=2.0;
else if(b>=62&&b<=65)
c=1.5;
else if(b>=60&&b<=61)
c=1.0;
else
c=0;
printf("\n该门的绩点为%.1f\n",c);
sum_a +=a; //计算总学分
sum_c +=a*c; //计算总绩点
}
aver=sum_c/sum_a;
printf("%lf",aver);
return 0;
}
|