uva1586 字符串与数组03-习题2
2017-04-07 16:56
176 查看
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cstring> #include <cctype> using namespace std; int main() { int t; int m=0; double sum=0; char s[88]; double a[30]={0,0,12.01,0,0,0,0,1.008,0,0,0,0,0,14.01,16.00}; scanf("%d",&t); while(t--) { sum=0; scanf("%s",s); int len=strlen(s); char p=s[0]; for(int i=0;s[i]!='\0';i++) { if(isalpha(s[i])) { p=s[i]; sum+=a[p-'A']; } else { m=s[i]-'0'; if(isdigit(s[i+1])) { m=(s[i]-'0')*10+(s[i+1]-'0'); i++; } sum+=a[p-'A']*(m-1); } } printf("%.3lf\n",sum); } return 0; }
相关文章推荐
- 字符串与数组03-例题3 Palindromes,UVa401
- 算典03_习题_02_Uva-1586
- 字符串与数组03-例题-2 (WERTYU,UVa 10082)
- 算法竞赛入门经典(第二版)-刘汝佳-第三章 数组与字符串 例题+习题(17/18)
- 数组_习题:将输入的字符串逆序输出
- 习题3-2 UVa1586
- (十一)黑马程序员——关于字符串和数组的习题总结(补充)
- 03- Shell脚本学习--字符串和数组
- 求出长度为1, 2, 3, 4, 5....的字符串最大出现次数 后缀数组 UVA 11855 - Buzzwords
- Uva 227 - Puzzle (数组和字符串)
- UVa 1586 - Molar mass【字符串】
- 习题8-2 UVA - 1610 Party Games 聚会游戏 (构造字符串)
- 数组-字符串_习题:输入一个英文字符串转换其大小写后输出
- UVa 1586 / UVALive 3900 Molar mass (字符串)
- UVa 1586 字符串处理
- 习题3-2 UVa 1586 Molar Mass
- Linq学习__03__数据源是IEnumerable<T> 变量,Concat,匿名类,数组下标,返回字符串,group by,orderby
- 小紫书 习题 3-2(UVA 1586) 分子量(Molar mass)
- 「算法竞赛入门经典 第二版」第 3 章 数组和字符串 习题解答
- c++ primer(第五版)学习笔记及习题答案代码版(第三章)字符串、向量和数组