2015年oj:多位数的处理

<h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Description</h2><div class="content" style="font-family: 'Times New Roman'; font-size: 20px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51); background: none 0px 0px repeat scroll rgb(228, 240, 248);"><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;">给出一个不多于5位的整数,要求 1、求出它是几位数 2、分别输出每一位数字 3、按逆序输出各位数字,例如原数为321,应输出123</p></div><h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Input</h2><div class="content" style="font-family: 'Times New Roman'; font-size: 20px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51); background: none 0px 0px repeat scroll rgb(228, 240, 248);"><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;">一个不大于5位的数字</p></div><h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Output</h2><div class="content" style="font-family: 'Times New Roman'; font-size: 20px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51); background: none 0px 0px repeat scroll rgb(228, 240, 248);"><p style="margin-top: 0px; margin-bottom: 9px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;">三行第一行 位数第二行 用空格分开的每个数字,注意最后一个数字后没有空格第三行 按逆序输出这个数</p></div><h2 style="margin: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizelegibility; font-size: 24px; line-height: 36px;">Sample Input</h2><pre class="content" style="padding: 8.5px; font-family: Menlo, Monaco, 'Courier New', monospace; font-size: 12.025px; color: rgb(51, 51, 51); border-radius: 4px; margin-top: 0px; margin-bottom: 9px; line-height: 18px; border: 1px solid rgba(0, 0, 0, 0.14902); white-space: pre-wrap; word-break: break-all; word-wrap: break-word; background-color: rgb(245, 245, 245);"><span class="sampledata" style="font-family: monospace; font-size: 18px; white-space: pre; background: none 0px 0px repeat scroll rgb(141, 184, 255);">12345</span>

Sample Output

5
1 2 3 4 

 
#include <iostream>
#include<string>
using namespace std;

int main()
{
    string s;
    int i;
    cin>>s;
    cout<<s.length()<<endl;
    for(i=0;i<s.length()-1; i++)
    {
        cout<<s[i]<<' ';
    }
    int m=s.length();
    cout<<s[m-1];
    cout<<endl;
    for(int m=s.length()-1;m>=0; --m)
    {
        cout<<s[m];
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值