您的位置:首页 > 其它

113.根据要求合并两个整数

2015-06-29 21:40 387 查看
函数fun的功能是:将a、b中的两个两位数整数合并形成一个新的整数放在c中。合并的方式是:将a的十位和个位依次放在变量c的百位和个位上,b中的十位和个位数依次放在变量的c放十位和千位上。

</pre><pre name="code" class="cpp">#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
void fun(int a,int b,long *c)
{
*c = a / 10 * 100 + a % 10 + b / 10 * 10 + b % 10 * 1000;
}
int main()
{
int a, b;
long c;
printf("Input a,b:");
scanf("%d%d", &a, &b);
fun(a, b, &c);
printf("The result is:%ld", c);
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: