美文网首页工作生活
C语言014 第十四课 置换变量值 2019-07-03

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

作者: 泥劳工 | 来源:发表于2019-07-03 23:39 被阅读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");

}

相关文章

网友评论

    本文标题:C语言014 第十四课 置换变量值 2019-07-03

    本文链接:https://www.haomeiwen.com/subject/iznhhctx.html