題目連結: https://zerojudge.tw/ShowProblem?problemid=a865
# 解題思路
最簡單的方法就是建表,加油!!你做得到!
# 程式碼
#include <iostream> | |
using namespace std; | |
int main(){ | |
string s; | |
int a[26]={1,2,600,4,5,500,3,9,10,0,20,30,40,50,70,80,90,100,200,300,400,0,800,60,8,7}; | |
while(cin>>s){ | |
if(s[0]=='.') | |
break; | |
cin.ignore(); | |
int sum=0; | |
for(int i=0;i<s.size();i++){ | |
if(s[i]>='A'&&s[i]<='Z') | |
sum+=a[s[i]-65]; | |
else if(s[i]=='#') | |
sum+=6; | |
else if(s[i]=='$') | |
sum+=700; | |
else | |
sum+=900; | |
} | |
cout<<sum<<endl; | |
} | |
} |