第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

UVA-1586不知道是哪里出錯,總是wa

UVA-1586不知道是哪里出錯,總是wa

慕用7336610 2018-09-21 22:58:08
InputYour program is to read from standard input. The input consists of?T?test cases. The number of test cases?T?is given in the first line of the input. Each test case is given in a single line, which contains a molecular formula as a string. The chemical symbol is given by a capital letter and the length of the string is greater than 0 and less than 80. The quantity number?n?which is represented after the chemical symbol would be omitted when the number is 1 (2n99) .?OutputYour program is to write to standard output. Print exactly one line for each test case. The line should contain the molar mass of the given molecular formula.?Sample Input?4? C? C6H5OH? NH2CH2COOH? C12H22O11?Sample Output?12.010? 94.108? 75.070? 342.296#include<iostream>#include<string.h>#include<ctype.h>#include<iomanip>using namespace std;int main(){int i,n,k,m,d,f;double s;char a[105][90];? ? while(cin>>n)? ? { memset(a,0,sizeof(a));? ? ? ? for(i=0;i<n;i++)? ? ? ? ? ? cin>>a[i];? ? ? ? ? ? for(i=0;i<n;i++)? ? ? ? {? ?m=strlen(a[i]);? ? ? ? s=0;? ? ? ? ? ? for(k=0;k<m;k++)? ? ? ? ? ? {if(isalpha(a[i][k])==1&&isdigit(a[i][k+1])==1)? ? ? ? ? ? ? {{d=a[i][k+1]-'0';? ? ? ? ? ? ? ? ? for(f=1;;f++)? ? {if(isdigit(a[i][k+f+1])==1)d=d*10+(a[i][k+f+1]-'0');else break;}}? ? ? ? ? ? ? ? switch(a[i][k])? ? ? ? ? ? ? ? {case'C':s+=12.01*d;break;? ? ? ? ? ? ? ? case'H':s+=1.008*d;break;? ? ? ? ? ? ? ? case'O':s+=16.00*d;break;? ? ? ? ? ? ? ? case'N':s+=14.01*d;break;}}? ? ? ? ? ? ? ? if(isalpha(a[i][k])==1&&isdigit(a[i][k+1])!=1)? ? ? ? ? ? ? ? switch(a[i][k])? ? ? ? ? ? ? ? {case'C':s+=12.01;break;? ? ? ? ? ? ? ? case'H':s+=1.008;break;? ? ? ? ? ? ? ? case'O':s+=16.00;break;? ? ? ? ? ? ? ? case'N':s+=14.01;break;}? ? ? ? ? ? ? ? if(isdigit(a[i][k])==1)? ? ? ? ? ? ? ? ? ? continue;? ? ? ? ? ? }? ? ? ? ? ? cout<<setiosflags(ios::fixed)<<setprecision(3)<<s<<endl;? ? ? ? }? ? }? ? return 0;}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 1245 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號