POJ 2256 Artificial Intelligence?
来源:互联网 发布:红杉树网络会议系统 编辑:程序博客网 时间:2024/05/17 04:13
P = U * I
有单位的转换。
就是个小模拟题。
#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main(){ int n; scanf("%d",&n); for(int i = 1 ; i <= n; i++) { double U=0,P=0,I=0; char c[1000]; int j = 0; while((c[j] = getchar())!='=') j++; if(c[j-1]=='U') { scanf("%lf",&U); c[++j]=getchar(); if(c[j]=='m') U*=0.001; else if(c[j]=='M') U *=1000000; else if(c[j]=='k') U *=1000; j++; } if(c[j-1]=='I') { scanf("%lf",&I); c[++j]=getchar(); if(c[j]=='m') I*=0.001; else if(c[j]=='M') I *=1000000; else if(c[j]=='k') I *=1000; j++; } if(c[j-1]=='P') { scanf("%lf",&P); c[++j]=getchar(); if(c[j]=='m') P*=0.001; else if(c[j]=='M') P *=1000000; else if(c[j]=='k') P *=1000; j++; } while((c[j] = getchar())!='=') j++; if(c[j-1]=='U') { scanf("%lf",&U); c[++j]=getchar(); if(c[j]=='m') U*=0.001; else if(c[j]=='M') U *=1000000; else if(c[j]=='k') U *=1000; j++; } if(c[j-1]=='I') { scanf("%lf",&I); c[++j]=getchar(); if(c[j]=='m') I*=0.001; else if(c[j]=='M') I *=1000000; else if(c[j]=='k') I *=1000; j++; } if(c[j-1]=='P') { scanf("%lf",&P); c[++j]=getchar(); if(c[j]=='m') P*=0.001; else if(c[j]=='M') P *=1000000; else if(c[j]=='k') P *=1000; j++; } printf("Problem #%d\n",i); if(P==0) { P = U*I; printf("P=%.2lfW\n",P); } else if(I==0) { I = P / U; printf("I=%.2lfA\n",I); } else if(U==0) { U = P / I ; printf("U=%.2lfV\n",U); } printf("\n"); } return 0;}
0 0
- POJ 2256 Artificial Intelligence?
- POJ 2256 Artificial Intelligence?
- POJ 2256 Artificial Intelligence?【字符串处理】
- POJ 2256 Artificial Intelligence?(字符串处理)
- Artificial Intelligence
- Artificial Intelligence?
- Artificial Intelligence?
- Artificial Intelligence?
- Artificial Intelligence?
- Artificial Intelligence?
- Artificial Intelligence?
- Artificial Intelligence?
- Artificial Intelligence
- Artificial Intelligence
- WHAT IS ARTIFICIAL INTELLIGENCE?
- Artificial Intelligence for Games
- Rethinking artificial intelligence
- 537-- Artificial Intelligence?
- Java学习笔记-异常
- 云平台--沉淀:ViewData 和ViewBag
- 小米3 打开USB调试设置方法。
- HDU 5174 Ferries Wheel (暴力小模拟)
- 在线支付一定需要支付宝吗?
- POJ 2256 Artificial Intelligence?
- 批量修改oracle 用户的表空间
- Palindrome Number
- 管理中的笑话,笑话中的管理(犹太人的智慧)
- 树与二叉树总结
- Linux下显示IP地理位置信息的小工具-nali
- 下午,南京东路、人民广场、人真是太多了!
- Oracle 分析函数Merge 案例
- (五十一)KVC与KVO详解