zoukankan      html  css  js  c++  java
  • poj3299

    这一题学会了两个东西:

    1.cmath中的exp(x)函数是用来求e的x次幂。

    2.对于double类型scanf时要用%lf,printf时要用%f。

    这个题就是个套公式的简单题

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

    int getid(char *st)
    {
    if (strcmp(st, "T") == 0)
    return 0;
    if (strcmp(st, "D") == 0)
    return 1;
    return 2;
    }

    void calt(double &t, double &d, double &h)
    {
    double e, hh;
    e
    = 6.11 * exp((5417.7530 * ((1 / 273.16) - (1 / (d + 273.16)))));
    hh
    = (0.5555) * (e - 10.0);
    t
    = h - hh;
    }

    void cald(double &t, double &d, double &h)
    {
    double e, hh;
    hh
    = h - t;
    e
    = hh / 0.5555 + 10.0;
    d
    = 1 / (1 / 273.16 - log(e / 6.11) / 5417.7530) - 273.16;
    }

    void calh(double &t, double &d, double &h)
    {
    double e, hh;
    e
    = 6.11 * exp((5417.7530 * ((1 / 273.16) - (1 / (d + 273.16)))));
    hh
    = (0.5555) * (e - 10.0);
    h
    = t + hh;
    }

    int main()
    {
    //freopen("D:\\t.txt", "r", stdin);
    char st[100];
    double data[3];
    while (scanf("%s", st) != EOF && !(strcmp(st, "E") == 0))
    {
    data[
    0] = data[1] = data[2] = 0;
    double a;
    scanf(
    "%lf", &a);
    data[getid(st)]
    = a;
    scanf(
    "%s", st);
    scanf(
    "%lf", &a);
    data[getid(st)]
    = a;
    getchar();
    if (data[0] == 0)
    calt(data[
    0], data[1], data[2]);
    if (data[1] == 0)
    cald(data[
    0], data[1], data[2]);
    if (data[2] == 0)
    calh(data[
    0], data[1], data[2]);
    printf(
    "T %.1f D %.1f H %.1f\n", data[0], data[1], data[2]);
    }
    return 0;
    }
  • 相关阅读:
    SCOI2003 字符串折叠
    UVA1629 Cake slicing
    POI2008 KLO-Building blocks
    NOI导刊2010提高 符文之语
    MongoDB数据库的基本操作
    React Naive 解决防止多次点击的解决方法
    如何自定义修改博客园样式
    语法对照表ES5VSES6
    MongoDB数据库安装
    小程序学习2 常用小程序概念以及代码实现
  • 原文地址:https://www.cnblogs.com/rainydays/p/1966790.html
Copyright © 2011-2022 走看看