UVA - UVA - 537 Artificial
来源:互联网 发布:怎样把nginx部署到公网 编辑:程序博客网 时间:2024/05/01 15:09
UVA - UVA - 537 Artificial Intelligence?
题目大意:给定两个量根据UI=P算第三个量
解题思路:跟据 ‘U=’ ‘I=’ ‘P=’ 读取 数据 需要注意打数 m k M 等单位换算 以及 A W V 需要注意匹配
#include <cstdio>#include <cstring>#include <cstdlib>int main() { int N; char a[10005]; scanf("%d",&N); getchar(); int t = 1,t1,t2,t3; float s11, s22, s33; char s1[100],s2[100],s3[100]; while (N--) { t1 = t2 = t3 = 0; s11 = s22 = s33 = 1; memset(a, 0 ,sizeof(a)); memset(s1, 0, sizeof(s1)); memset(s2, 0, sizeof(s2)); memset(s3, 0, sizeof(s3)); gets(a); for ( int i = 0; i < strlen(a); i++) { if (a[i] == 'U' && a[i+1] == '=') { t1 = 1; for (int j = 0; a[i+j+2] != 'V'; j++) { if ( a[i+j+2] == 'M' ) s11 = 1000000; else if ( a[i+j+2] == 'm') s11 = 0.001; else if ( a[i+j+2] == 'k') s11 = 1000; else s1[j] = a[i+j+2]; } } if (a[i] == 'I' && a[i+1] == '=') { t2 = 1; for (int j = 0; a[i+j+2] != 'A'; j++) { if ( a[i+j+2] == 'M' ) s22 = 1000000; else if ( a[i+j+2] == 'm') s22 = 0.001; else if ( a[i+j+2] == 'k') s22 = 1000; else s2[j] = a[i+j+2]; } } if (a[i] == 'P' && a[i+1] == '=') { t3 = 1; for (int j = 0; a[i+j+2] != 'W'; j++) { if ( a[i+j+2] == 'M' ) s33 = 1000000; else if ( a[i+j+2] == 'm') s33 = 0.001; else if ( a[i+j+2] == 'k') s33 = 1000; else s3[j] = a[i+j+2]; } } } if (t1 == 1 && t2 == 1) printf("Problem #%d\nP=%.2lfW\n", t, s11*s22*atof(s1)*atof(s2)); if (t3 == 1 && t2 == 1) printf("Problem #%d\nU=%.2lfV\n", t, s22*s33*atof(s3)/atof(s2)); if (t1 == 1 && t3 == 1) printf("Problem #%d\nI=%.2lfA\n", t, s11*s33*atof(s3)/atof(s1)); t++; printf("\n"); }}
0 0
- UVA - UVA - 537 Artificial
- uva 537 Artificial Intelligence?
- UVa 537 - Artificial Intelligence?
- UVa 537 - Artificial Intelligence?
- UVa 537 - Artificial Intelligence?
- UVA-537 - Artificial Intelligence?
- uva 537 - Artificial Intelligence?
- uva 537 Artificial Intelligence?
- UVA 537 - Artificial Intelligence?
- UVa 537 - Artificial Intelligence?
- UVA 537Artificial Intelligence?
- UVA 537 Artificial Intelligence?
- UVa 537: Artificial Intelligence?
- UVA 537 Artificial Intelligence?
- UVA 537 Artificial Intelligence?
- uva 537 Artificial Intelligence?
- uva - 537 - Artificial Intelligence?
- UVa 537 - Artificial Intelligence?
- UVA - 1588 Kickdown
- 自定义TTF多语言版本之台湾繁体
- UVA - 10361 Automatic Poetry
- 九、STL算法-变值算法(copy、transform)
- Cocos2D-ObjC:在RPG游戏中混合Swift代码
- UVA - UVA - 537 Artificial
- 基于Yarn平台的MapReduce运行机制
- UVA - 409 Excuses, Excuses!
- UVA - 10878 Decode the tape
- NOIP提高组A组7.7模拟总结
- Dynamic len
- UVA - 644 Immediate Decodability
- css3新增属性设置图片特效
- UVA - 10115 Automatic Editing