| Welcome to Leon's Blog |
|
|||
|
日歷
統(tǒng)計(jì)
導(dǎo)航常用鏈接留言簿(4)隨筆分類隨筆檔案
ACM搜索最新評(píng)論
|
好長(zhǎng)時(shí)間沒(méi)有寫程序了,敲代碼+調(diào)試花了我2個(gè)小時(shí)時(shí)間,就為了一道特簡(jiǎn)單題目(acm3299),以后要多多鍛煉才行。
代碼如下: 1
#include <stdio.h>2 #include <math.h>3 ![]() 4 const float E = 2.718281828;5 ![]() 6 int 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 for( int 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 d41 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 ----t46 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 ---d50 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 ![]()
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|
| Copyright © Leon916 | Powered by: 博客園 模板提供:滬江博客 |