AcWing 1477. 拼写正确(to_string 语法糖 )

2021-03-15 20:21:53 浏览数 (1)

to_string知道的话会好写很多吧~

代码语言:javascript复制
#include<bits/stdc  .h>
using namespace std;
char s[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main(){
    string p;
    cin>>p;
    int res=0;
    for(auto it:p){
        res =it-'0';
    }
    p=to_string(res);
    for(auto it:p){
        cout<<s[it-'0']<<" ";
    }
}

0 人点赞