?? 1202 the calculation of gpa.cpp
字號:
/*
1202 The calculation of GPA
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 256 K
GUN C++
*/
#include <iostream.h>
using namespace std;
#define MAX 1000
int main()
{
int t,ca,point;
float s,p,gpa,ssum;
cout.setf(ios::fixed);
cout.precision(2);
while(cin>>t)
{
ssum=gpa=0;
for(ca=0;ca<t;ca++)
{
cin>>s>>p;
/*if(p==-1)
continue;
point=0;
ssum+=s;
有問題, p=-1時候,不計算學分,和績點的.
改為if (p!= -1 )*/
if(p!=-1)
{
ssum+=s;
point=0;
if(p>=60 && p<=100)
{
point=1;
if(p>=70)
{
point=2;
if(p>=80)
{
point=3;
if(p>=90)
point=4;
}
}
}//end point
//cout<<point<<endl;
gpa+=point*s;
}//if
}
if(ssum!=0)
cout<<gpa/ssum<<endl;
else
cout<<-1<<endl;
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -