⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1202 the calculation of gpa.cpp

📁 ACM 威士忌部分答案
💻 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 + -