PAT甲级1005 Spell It Right :[C++题解]字符串处理
生活随笔
收集整理的這篇文章主要介紹了
PAT甲级1005 Spell It Right :[C++题解]字符串处理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 題目分析
- 題目鏈接
題目分析
ac代碼
#include<bits/stdc++.h> using namespace std;const int N =110;string num;map<char,string> mp ={{'0',"zero"},{'1',"one"},{'2',"two"},{'3',"three"},{'4',"four"},{'5',"five"},{'6',"six"},{'7',"seven"},{'8',"eight"},{'9',"nine"} };int main(){cin>>num;int res =0;for(int i=0;i<num.size();i++){res +=num[i]-'0';}string res1 = to_string(res);// cout<<res1<<endl;for(int i=0;i<res1.size();i++){if(i<res1.size()-1)cout<< mp[res1[i]] <<" ";else cout<< mp[res1[i]];}}題目鏈接
PAT甲級1005 Spell It Right
總結
以上是生活随笔為你收集整理的PAT甲级1005 Spell It Right :[C++题解]字符串处理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PAT甲级1001 A+B Format
- 下一篇: PAT甲级1006 Sign In an