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)
  • 相关阅读:
    c# 并行运算二
    c# 并行运算
    Task+http请求
    Task多线程
    SSO系统认证
    web系统权限设计
    AutoMapper的使用
    中间件
    express-middleware
    中间件概念
  • 原文地址:https://www.cnblogs.com/lochan/p/3451775.html
Copyright © 2011-2022 走看看