hdoj 1202 the calculation of GPA(水题)
2017-12-20 14:59
295 查看
思路:直接给代码了
代码如下:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int n;
double s,p;
double sum1,sum2;
while(scanf("%d",&n)!=EOF)
{
sum1=sum2=0.0;
while(n--)
{
scanf("%lf%lf",&s,&p);
if((int)p+1==0)
continue;
sum1+=s;
if(p>=90)
sum2+=4*s;
else if(p>=80)
sum2+=3*s;
else if(p>=70)
sum2+=2*s;
else if(p>=60)
sum2+=s;
}
if(sum1!=0)
printf("%.2lf\n",sum2/sum1);
else
printf("-1\n");
}
return 0;
}
代码如下:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int n;
double s,p;
double sum1,sum2;
while(scanf("%d",&n)!=EOF)
{
sum1=sum2=0.0;
while(n--)
{
scanf("%lf%lf",&s,&p);
if((int)p+1==0)
continue;
sum1+=s;
if(p>=90)
sum2+=4*s;
else if(p>=80)
sum2+=3*s;
else if(p>=70)
sum2+=2*s;
else if(p>=60)
sum2+=s;
}
if(sum1!=0)
printf("%.2lf\n",sum2/sum1);
else
printf("-1\n");
}
return 0;
}
相关文章推荐
- HDOJ HDU 1202 The calculation of GPA ACM 202 IN HDU
- hdoj1202_The calculation of GPA
- HDOJ 1202 The calculation of GPA
- HDU-1202-The calculation of GPA(恶心水题)
- HDOJ 1202 The calculation of GPA
- HDOJ 1202 The calculation of GPA
- HDOJ 1202 The calculation of GPA
- HDOJ 1202 The calculation of GPA
- hdu 1202 The calculation of GPA
- hdu 1202 The calculation of GPA
- 杭电1202 The calculation of GPA
- Problem : 1202 ( The calculation of GPA )
- HDU 1202 The calculation of GPA
- HDU 1202 The calculation of GPA(数学)
- hdu 1202 The calculation of GPA
- hdu_1202 The calculation of GPA
- HDU 1202 The calculation of GPA
- HDU 1202 the calculation of GPA
- 杭电 HDU 1202 The calculation of GPA
- 1202 The calculation of GPA