• 【PAT甲级】1005 Spell It Right (20 分)


    题意:

    给出一个非零整数N(<=10^100),计算每位之和并用英文输出。

    AAAAAccepted code:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 string s;
     4 char num[17][17]={"zero","one","two","three","four","five","six","seven","eight","nine"};
     5 int main(){
     6     cin>>s;
     7     int ans=0;
     8     for(int i=0;i<s.length();++i)
     9         ans+=s[i]-'0';
    10     int x=ans/100;
    11     ans%=100;
    12     int y=ans/10;
    13     ans%=10;
    14     int z=ans;
    15     if(x)
    16         cout<<num[x]<<" "<<num[y]<<" "<<num[z];
    17     else if(y)
    18         cout<<num[y]<<" "<<num[z];
    19     else
    20         cout<<num[z];
    21     return 0;
    22 }
    保持热爱 不懈努力 不试试看怎么知道会失败呢(划掉) 世上无难事 只要肯放弃(划掉)
  • 相关阅读:
    WPF基础篇之静态资源和动态资源
    15-Node-数据库
    15-Node
    12-Git
    总-S04-03 项目-大事件
    00-PHP难点
    08-PHP基础
    15-ES6
    16-Vue-webpack
    00-Web难点
  • 原文地址:https://www.cnblogs.com/ldudxy/p/11215664.html
Copyright © 2020-2023  润新知