问题标题: 看下

0
0
已解决
张司桥
张司桥
中级光能
中级光能

看下

张司桥在2024-06-03 18:01:43追加了内容

题目描述 Description

输入两个整数,数字的位数不超过100位,如果这第一个整数和第二个整数同为奇数或者同为偶数,那么输出第二个整数连接在第一个整数后的数字,否则输出第一个整数连接在第二个整数后的数字。

输入描述 Input Description

第一行:第一个整数
第二行:第二个整数,两个整数的位数都不超过100位

输出描述 Output Description

输出连接后的结果

样例输入 Sample Input

34565678 34567854

样例输出 Sample Output

3456567834567854

不会,只能这样了

 

张司桥在2024-06-03 18:02:06追加了内容

求大佬解惑


0
已采纳
张洪睿
张洪睿
高级光能
高级光能

我觉得这道题可以定义两个字符串a和b

然后是if判断

如果a第a的长度减1位(最后一个字符)减去b第b的长度减1位(最后一个字符)的绝对值(abs,记得加头文件)模2为0,那么输出b加a

简化一下
abs(a[a的长度-1]-b[b的长度-1])模2

否则输出a加b

0
朱一鸣
朱一鸣
新手光能
新手光能

用字符串,连接就用字符串a+字符串b,判断奇偶数就用字符串(最后一个字母-‘0’)%2

0
0
倪雨泽
倪雨泽
中级光能
中级光能

思路:

string a,b; 输入 分别判断最后一位是奇数还是偶数

全奇数输出a+b,

否则输出b+a

判断很简单

仅需判断a[长度-1]-'0'和b[长度-1]-'0'即可






[Charlie Puth]

It's been a long day without you my friend

And I'll tell you all about it when I see you again

We've come a long way from where we began

Oh I'll tell you all about it when I see you again

When I see you again

[Wiz Khalifa]

Damn, who knew all the planes we flew

Good things we've been through

That I'll be standing right here

Talking to you about another path

I know we loved to hit the road and laugh

But something told me that it wouldn't last

Had to switch up look at things different see the bigger picture

Those were the days hard work forever pays

Now I see you in a better place

How could we not talk about family when family's all that we got?

Everything I went through you were standing there by my side

And now you gonna be with me for the last ride

[Charlie Puth]

It's been a long day without you my friend

And I'll tell you all about it when I see you again

We've come a long way from where we began

Oh I'll tell you all about it when I see you again

When I see you again

[Wiz Khalifa]

First you both go out your way

And the vibe is feeling strong and what's small turn to a friendship

A friendship turn into a bond and that bond will never be broken and the love will never get lost

And when brotherhood come first then the line

Will never be crossed established it on our own

When that line had to be drawn and that line is what

We reach so remember me when I'm gone

How could we not talk about family when family's all that we got?

Everything I went through you were standing there by my side

And now you gonna be with me for the last ride

[Charlie Puth]

So let the light guide your way

Hold every memory as you go

And every road you take will always lead you home

Hoo~

It's been a long day without you my friend

And I'll tell you all about it when I see you again

We've come a long way from where we began

Oh I'll tell you all about it when I see you again

When I see you again

When I see you again, see you again

When I see you again

0
我要回答