Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
14619 周百诚 相对分子质量 C++ Accepted 4 MS 732 KB 757 2021-06-28 20:56:15

Tests(1/1):


Code:

#include<iostream> #include<cstdio> #include<cstring> //使用strlen函数前要调用<cstring> using namespace std; int main() { int n,i,e,j,c; int temp = 0; int all = 0; string str; cin>>n; for(i =0;i<n;i++) { cin>>str; int len = str.size(); all = 0 ; for(j=0;j<len;j++) { temp =0; switch(str[j]) { case 'H':temp = 1;break; case 'C':temp = 12;break; case 'N':temp = 14;break; case 'O':temp = 16;break; case 'F':temp = 19;break; case 'P':temp = 31;break; case 'S':temp = 32;break; case 'K':temp = 39;break; } if(str[j+1]>='1'&&str[j+1]<='9') { temp *= str[j+1]-'0'; } all += temp; } cout<<all<<endl; } return 0; }