POJ 3299
来源:互联网 发布:计算流体力学软件 编辑:程序博客网 时间:2024/05/14 09:38
#include <stdio.h>
#include <math.h>
double eForExp = 2.718281828;
double getT(double D, double H) {
double h = 0.5555 * (6.11 * pow(eForExp, (5417.7530 * ((1/273.16) - (1/(D + 273.16))))) - 10.0);
printf("T %.1f D %.1f H %.1f\n", H - h, D ,H);
return H - h;
}
double getD(double T, double H) {
double D = 1/(1/273.16 - log(((H - T)/(0.5555) + 10.0)/6.11)/5417.7530) - 273.16;
printf("T %.1f D %.1f H %.1f\n", T, D, H);
return D;
}
double getH(double T, double D) {
double H = T + (0.5555) * (6.11 * exp(5417.7530 * (1/273.16 - 1/(D + 273.16))) - 10);
printf("T %.1f D %.1f H %.1f\n", T, D, H);
return H;
}
void caculate(double T, double D, double H) {
if (T == 200) {
getT(D, H);
} else if (D == 200) {
getD(T, H);
} else if (H == 200) {
getH(T, D);
}
}
int main() {
double D = 200.0;
double T = 200.0;
double H = 200.0;
int lineParamNum = 0;
while(1) {
char c = 0;
scanf("%c", &c);
lineParamNum += 1;
if (c == 'D') {
scanf("%lf", &D);
} else if (c == 'T') {
scanf("%lf", &T);
} else if (c == 'H') {
scanf("%lf", &H);
} else if (c == ' '){
continue;
} else if (c == '\n'){
caculate(T, D, H);
D = 200.0;
T = 200.0;
H = 200.0;
lineParamNum = 0;
continue;
} else {
break;
}
}
#include <math.h>
double eForExp = 2.718281828;
double getT(double D, double H) {
double h = 0.5555 * (6.11 * pow(eForExp, (5417.7530 * ((1/273.16) - (1/(D + 273.16))))) - 10.0);
printf("T %.1f D %.1f H %.1f\n", H - h, D ,H);
return H - h;
}
double getD(double T, double H) {
double D = 1/(1/273.16 - log(((H - T)/(0.5555) + 10.0)/6.11)/5417.7530) - 273.16;
printf("T %.1f D %.1f H %.1f\n", T, D, H);
return D;
}
double getH(double T, double D) {
double H = T + (0.5555) * (6.11 * exp(5417.7530 * (1/273.16 - 1/(D + 273.16))) - 10);
printf("T %.1f D %.1f H %.1f\n", T, D, H);
return H;
}
void caculate(double T, double D, double H) {
if (T == 200) {
getT(D, H);
} else if (D == 200) {
getD(T, H);
} else if (H == 200) {
getH(T, D);
}
}
int main() {
double D = 200.0;
double T = 200.0;
double H = 200.0;
int lineParamNum = 0;
while(1) {
char c = 0;
scanf("%c", &c);
lineParamNum += 1;
if (c == 'D') {
scanf("%lf", &D);
} else if (c == 'T') {
scanf("%lf", &T);
} else if (c == 'H') {
scanf("%lf", &H);
} else if (c == ' '){
continue;
} else if (c == '\n'){
caculate(T, D, H);
D = 200.0;
T = 200.0;
H = 200.0;
lineParamNum = 0;
continue;
} else {
break;
}
}
}
注意%.1lf 在G++下printf不能用, 要用 %.1f
ugly code.
0 0
- poj 3299
- POJ 3299
- poj 3299
- POJ 3299
- poj 3299
- POJ 3299
- POJ 3299
- poj 3299
- POJ 3299
- poj 3299
- poj 3299
- poj 3299
- POJ 3299
- poj 3299
- POJ 3299
- POJ 3299
- POJ 3299
- poj 3299
- java.lang包中的public final Math类
- magento -- 修改代码让后台属性组合里的属性显示中文
- 顶级pom和子pom版本批量修改
- LEADTOOLS Silverlight Demo演示大全
- List转DataTable(反射)
- POJ 3299
- ORACLE 临时表空间使用率过高的原因及解决方案
- Struts2之类型转换
- AE+C# GP批量裁剪
- Android 图片OutOfMemory异常bitmap size exceeds VM budget的原因及解决方法
- html table 表格导出到Excel
- Eclipse 插件开发 打开Windows资源管理器
- HTML学习笔记,基础知识篇
- struts2学习笔记(1)------写第一个struts程序