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;
    }
  • 相关阅读:
    【MVC】过滤器
    【C#】开发可以可视化操作的windows服务
    【JS】导出table到excel,同时兼容FF和IE
    【.Net】文件并发(日志处理)--队列--Redis+Log4Net
    【.Net】从.NET平台调用Win32 API
    『录』最全前端资源汇集
    $.ajax()方法详解
    mvc的视图中显示DataTable的方法
    C# 对XML基本操作总结
    Ninject简介
  • 原文地址:https://www.cnblogs.com/rainydays/p/1966790.html
Copyright © 2011-2022 走看看