标签:blog io ar for div log amp as tt
#include<stdio.h> struct mem { char s[50]; double c; double f; }; int main() { struct mem x[60]; int n; int num,i,flag;//num为课程数量 scanf("%d",&n); while(n--) { double sum1=0,sum2=0,gpa; scanf("%d",&num); for(i=0;i<num;i++) { scanf("%s",x[i].s); scanf("%lf",&x[i].c); scanf("%lf",&x[i].f); } for(i=0;i<num;i++) { if(x[i].f>=0&&x[i].f<60) { printf("Sorry!\n"); flag=0; break; } else { sum1+=x[i].c*x[i].f; sum2+=x[i].c; } } if(flag) { gpa=(sum1*1.0)/sum2; printf("%.2lf\n",gpa); } if(n<=1) { printf("\n"); } } }
找不出错误在哪,待解决
标签:blog io ar for div log amp as tt
原文地址:http://www.cnblogs.com/wuyuewoniu/p/4032002.html