| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:C++ 就AC G++ 是WA 好诡异的测试~~~(附代码)In Reply To:C++ 就AC G++ 是WA 好诡异的测试~~~(附代码) Posted by:447409410 at 2011-07-10 10:56:49 > #include<iostream>
> #include<cstdio>
> #include<string>
> #include<cstring>
> #include<cmath>
> #include<algorithm>
>
> #define exp 2.718281828
>
> using namespace std;
>
> double tem,dew,hum;
> double h,e;
> char start,indor,end;
> double a,b;
>
> int main()
> {
> int cacolate(char &a, double &x, char &b, double &y);
>
> while(scanf("%c",&start)!=EOF && (start!='E'))
> {
> scanf("%lf %c %lf",&a,&indor,&b);
> getchar();
> cacolate(start,a,indor,b);
> }
>
> return 0;
> }
>
> int cacolate(char &a, double &x, char &b, double &y)
> {
> if(a=='T' && b=='D')
> {
> tem=x;
> dew=y;
> e=6.11*pow(exp,(5417.7530 * ((1/273.16) - (1/(dew+273.16)))));
> h=(0.5555)* (e - 10.0);
> hum=tem+h;
> // return hum;
> cout<<"T ";
> printf("%.1lf",tem);
> cout<<" D ";
> printf("%.1lf",dew);
> cout<<" H ";
> printf("%.1lf\n",hum);
> return 0;
> }
> else if(a=='D' && b=='T')
> {
> tem=y;
> dew=x;
> e=6.11*pow(exp,(5417.7530 * ((1/273.16) - (1/(dew+273.16)))));
> h=(0.5555)* (e - 10.0);
> hum=tem+h;
> // return hum;
> cout<<"T ";
> printf("%.1lf",tem);
> cout<<" D ";
> printf("%.1lf",dew);
> cout<<" H ";
> printf("%.1lf\n",hum);
> return 0;
> }
> else if(a=='D' && b=='H')
> {
> dew=x;
> hum=y;
> e=6.11*pow(exp,(5417.7530 * ((1/273.16) - (1/(dew+273.16)))));
> h=(0.5555)* (e - 10.0);
> tem=hum-h;
> cout<<"T ";
> printf("%.1lf",tem);
> cout<<" D ";
> printf("%.1lf",dew);
> cout<<" H ";
> printf("%.1lf\n",hum);
> return 0;
> }
> else if(a=='H' && b=='D')
> {
> dew=y;
> hum=x;
> e=6.11*pow(exp,(5417.7530 * ((1/273.16) - (1/(dew+273.16)))));
> h=(0.5555)* (e - 10.0);
> tem=hum-h;
> cout<<"T ";
> printf("%.1lf",tem);
> cout<<" D ";
> printf("%.1lf",dew);
> cout<<" H ";
> printf("%.1lf\n",hum);
> return 0;
> }
> else if(a=='H' && b=='T')
> {
> hum=x;
> tem=y;
> h=hum-tem;
> e=h/0.5555+10.0;
> dew=1/(1/273.16-log(e/6.11)/5417.7530)-273.16;
> cout<<"T ";
> printf("%.1lf",tem);
> cout<<" D ";
> printf("%.1lf",dew);
> cout<<" H ";
> printf("%.1lf\n",hum);
> return 0;
> }
> else if(a=='T' && b=='H')
> {
> hum=y;
> tem=x;
> h=hum-tem;
> e=h/0.5555+10.0;
> dew=1/(1/273.16-log(e/6.11)/5417.7530)-273.16;
> cout<<"T ";
> printf("%.1lf",tem);
> cout<<" D ";
> printf("%.1lf",dew);
> cout<<" H ";
> printf("%.1lf\n",hum);
> return 0;
> }
> }
你不觉得你的代码重复了吗?Don't repeat yourself!
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator