zoukankan      html  css  js  c++  java
  • poj1929

    无算法,但有些麻烦

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    using namespace std;

    #define maxl 100
    #define eps 10E-9

    char st[maxl];
    char unit;
    double fat;
    double tot;

    void input()
    {
    int temp;
    char ch;
    sscanf(st,
    "%d%c", &temp, &ch);
    bool percent;
    int p = 0;
    int c = 0;
    if (ch == '%')
    {
    percent
    = true;
    p
    += temp;
    }
    else if (ch == 'g')
    {
    percent
    = false;
    c
    += temp * 9;
    fat
    += temp * 9;
    }
    else
    {
    percent
    = false;
    c
    += temp;
    fat
    += temp;
    }
    int f[4] =
    {
    4, 4, 4, 7 };
    for (int i = 0; i < 4; i++)
    {
    int a;
    scanf(
    "%d%c", &a, &ch);
    if (ch == '%')
    p
    += a;
    else if (ch == 'g')
    c
    += a * f[i];
    else
    c
    += a;

    }
    tot
    += c / (100.0 - p) * 100;
    if (percent)
    fat
    += c / (100.0 - p) * temp;
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    while (scanf("%s", st), strcmp(st, "-"))
    {
    fat
    = 0;
    tot
    = 0;
    do
    {
    input();
    }
    while (scanf("%s", st), strcmp(st, "-"));
    printf(
    "%d%%\n", (int)(fat * 100 / tot + 0.5 + eps));
    }
    return 0;
    }
  • 相关阅读:
    1334: 好老师
    poj 2255 Tree Recovery
    2006浙大:简单计算器
    POJ1001(C++处理大数)
    HDU2159(二维完全背包)
    POJ2080:Calendar(计算日期)
    2008上交:Day of Week
    POJ1365:质因数分解
    VIJOS:P1706(舞会)
    POJ2449:K短路
  • 原文地址:https://www.cnblogs.com/rainydays/p/2155985.html
Copyright © 2011-2022 走看看