简单的C语言编程题自己研究的,编程环境 visual studio 2013.
代码如下:
#include "stdio.h"
int main()
{
int a = 0;
int b = 0;
int count = 0;
printf("请输入两个数:");
scanf("%d%d", &a, &b);
count = a;
a = b;
b = count;
printf("%d,%d\n", a, b);
return 0;
}
附加:. 不允许创建临时变量,交换两个数的内容,我列出一种如果大家有新方法可以交流!
#include "stdio.h"
int test(int x, int y);
int main()
{
int a = 0;
int b = 0;
printf("请输入两个数:");
scanf("%d%d", &a, &b);
test(a , b );
return 0;
}
int test( int x,int y)
{
x = x + y;
y = x - y ;
x = x - y;
printf("%d,%d\n", x, y);
return 0;
}