工作生活

C语言014 第十四课 置换变量值 2019-07-03

2019-07-03  本文已影响0人  泥劳工

这个会顺序结构代码的一种例子,置换两个变量的值

输入 a=1 b=2 输出 a=2 b=1

#include "stdio.h"

void test2(void);

main()

{

test2();

return 0;

}

void test2(void)

{

int a,b,c;

printf("input a,b:");

scanf("%d%d",&a,&b);

c=a;

a=b;

b=c;

printf("The result is : a=%d,b=%d\n",a,b);

printf("this is test2.\n");

}

上一篇 下一篇

猜你喜欢

热点阅读