zoukankan      html  css  js  c++  java
  • HDU4802_GPA

    水题。

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    using namespace std;
    
    double totsum,totnum,k;
    char s[5];
    int n;
    
    double get()
    {
        if (s[0]=='A')
        {
            if (s[1]==0) return 4;
            else return 3.7;
        }
        if (s[0]=='B')
        {
            if (s[1]==0) return 3;
            else if (s[1]=='+') return 3.3;
            else return 2.7;
        }
        if (s[0]=='C')
        {
            if (s[1]==0) return 2;
            else if (s[1]=='+') return 2.3;
            else return 1.7;
        }
        if (s[0]=='D')
        {
            if (s[1]==0) return 1.3;
            else return 1;
        }
        if (s[0]=='F') return 0;
        return -1;
    }
    
    int main()
    {
        while (scanf("%d",&n)!=EOF)
        {
            totsum=totnum=0;
            while (n--)
            {
                scanf("%lf%s",&k,s);
                double tep=get(); //cout<<" this is : "<<tep<<endl;
                if (tep<0) continue;
                totnum+=k;
                totsum+=k*tep;
            }
            if (totnum==0) printf("0.00
    ");
                else printf("%.2f
    ",totsum/totnum);
        }
        return 0;
    }
    如有转载,请注明出处(http://www.cnblogs.com/lochan)
  • 相关阅读:
    加工零件(Dijkstra)
    尼克的任务(DP)
    挖地雷(记忆化搜索)
    滑雪(DP,记忆化搜索)
    子串和子序列(DP)
    八皇后(DFS)
    打印feign报错日志
    restTemplate 踩坑
    共享全局对象
    获取当月多少天
  • 原文地址:https://www.cnblogs.com/lochan/p/3451775.html
Copyright © 2011-2022 走看看