解题思路:把数字转换成字符串。





注意事项:





参考代码:

#include <iostream>

#include <string.h> 

using namespace std;

void shun_order(char m[] , int n)

{

int p ;

for(p = 0 ; p < n-1 ; p++)

cout << m[p]<<" ";

cout << m[n-1] << endl ;

}

void ni_order(char a[] , int b)

{

int t,i;

for(i = 0; i < b/2; i++)

{

t = a[i] , a[i] = a[b-i-1] , a[b-i-1] = t ;

}

for(i = 0; i < b; i++)

cout << a[i];

}

int main()

{

   char number[100];

   int len;

   cin>>number;   

   len = strlen(number);

   cout<<len<<endl; ;

   shun_order(number,len);

   ni_order(number,len);

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

这种是万能法,无论是几位数都适用。
2018-01-30 10:30:31
  • «
  • 1
  • »