网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  PAT-1005 Spell It Right

PAT-1005 Spell It Right

分类: IT文章 • 2022-05-21 13:04:42

题目

PAT-1005 Spell It Right 代码

#include <bits/stdc++.h>
using namespace std;
string s[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int a[1000];
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string in;
    cin>>in;
    int sum=0;
    for(int i=0;i<in.size();i++){
        sum+=in[i]-'0';
    }
    int index=0;
    while(sum){
        a[index++]=sum%10;
        sum/=10;
    }
    for(int i=index-1;i>=1;i--){
        cout<<s[a[i]]<<" ";
    }
    cout<<s[a[0]]<<endl;
    return 0;
}

相关推荐

  • left join 、right join 、inner join之间的区别
  • right way check file open and end
  • [转]Mysql字符串截取总结:left()、right()、substring()、substring
  • Face The Right Way---hdu3276(开关问题)
  • [leetcode] Populating Next Right Pointers in Each Node
  • 436. Find Right Interval
  • POJ:3276-Face The Right Way(线性反转)
  • mysql插入数据报错一二   报错一:Data truncated for column 'update_time' at row 1   报错二:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
  • 【计算几何】Oblongs and Right Triangles
  • 最常用的截取函数有left,right,substring
  • 【Django笔记一】windows系统下搭建Django项目
  • PAT1003 Emergency
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号