风丿千钧


私信TA

用户名:743419451

访问量:441

签 名:

等  级
排  名 51483
经  验 243
参赛次数 0
文章发表 2
年  龄 0
在职情况 学生
学  校 广东技术师范大学
专  业

  自我简介:

解题思路:这道题用数组做会方便一点。如果不想用数组做,就需要像下面这么麻烦。

注意事项:建议还是学习用数组做

参考代码:

#include<iostream>

using namespace std;

int main()

{

int x, n;

cin >> x;

if (x < 100000)

{

int a = x / 10000;

int b = x / 1000 - 10 * a;

int c = x / 100 - 100 * a - 10 * b;

int d = x / 10 - 1000 * a - 100 * b - 10 * c;

int e = x - 10000 * a - 1000 * b - 100 * c - 10 * d;

if (a > 0)

{

cout << 5 << endl;

cout << a << " " << b << " " << c << " " << d << " " << e << endl;

cout << e << d << c << b << a << endl;

}

else if (b > 0)

{

cout << 4 << endl;

cout << b << " " << c << " " << d << " " << e << endl;

cout << e << d << c << b  << endl;

}

else if (c > 0) 

{

cout << 3 << endl;

cout << c << " " << d << " " << e << endl;

cout << e << d << c  << endl;

}

else if (d > 0)

{

cout << 2 << endl;

cout <<  d << " " << e << endl;

cout << e << d  << endl;

}

else if (e > 0)

{

cout << 1 << endl;

cout<< e << endl;

cout << e << endl;

}

}

return 0;


 

0.0分

0 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区