zoukankan      html  css  js  c++  java
  • 【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 }
    保持热爱 不懈努力 不试试看怎么知道会失败呢(划掉) 世上无难事 只要肯放弃(划掉)
  • 相关阅读:
    交互题
    线段树
    最小生成树
    拓扑排序
    欧拉回路
    RMQ问题
    dfs序与求子树子节点(染了色)的个数
    dp题
    树状数组与离散化
    没做完的题
  • 原文地址:https://www.cnblogs.com/ldudxy/p/11215664.html
Copyright © 2011-2022 走看看