Welcome to Leon's Blog  
日历
<2009年9月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
统计
  • 随笔 - 30
  • 文章 - 0
  • 评论 - 51
  • 引用 - 0

导航

常用链接

留言簿(4)

随笔分类

随笔档案

ACM

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 
       好长时间没有写程序了,敲代码+调试花了我2个小时时间,就为了一道特简单题目(acm3299),以后要多多锻炼才行。
 代码如下:
 1#include <stdio.h>
 2#include <math.h>
 3
 4const float E = 2.718281828;
 5
 6int main(int argc, char *argv[])
 7{
 8    float t, d, h, e, hh;
 9    int index;
10    char temp;
11
12    while( (scanf("%c"&temp) == 1&& (temp != 'E'))
13    {
14        index = 0;
15        forint i = 0 ; i < 2;i++)
16        {
17            switch(temp)
18            {
19            case 'T':
20                index |= 0x1;
21                scanf("%f"&t);
22                break;
23            case 'D':
24                index |= 0x2;
25                scanf("%f"&d);
26                break;
27            case 'H':
28                index |= 0x4;
29                scanf("%f"&h);
30                break;
31            default:
32                i--;
33                break;
34            }

35            scanf("%c",&temp);
36        }

37        switch(index)
38        {
39            
40        case 3:  // t d
41            e = 6.11 * exp(5417.7530*((1/273.16-(1/(d+273.16))));
42            hh = (0.5555* (e - 10.0);
43            h = t + hh;
44            break;
45        case 6:        //d, h ----t
46            e = 6.11 * exp(5417.7530*((1/273.16-(1/(d+273.16))));
47            t = h - 0.5555 * (e - 10.0); 
48            break;
49        case 5:            //t h ---d
50            double e;
51            e = (h-t)/0.5555 + 10.0;
52            d = 1/((1/273.16- (log(e/6.11))/5417.753- 273.16;
53            break;
54        }

55        printf("T %.1f D %.1f H %.1f\n", t, d, h);
56    }

57    return 0;
58}

59
posted on 2009-09-11 17:08 Leon916 阅读(179) 评论(0)  编辑 收藏 引用 所属分类: c++学习

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


 
Copyright © Leon916 Powered by: 博客园 模板提供:沪江博客