【C语言作业】交换变量的值

第一种方法:

#include <stdio.h>
int main()
{
 int a,b,c;
 scanf("%d %d",&a,&b);
 c=b;
 b=a;
 a=c;
 printf("%d %d\n",a,b);
 return 0;
}

第二种方法:

#include<stdio.h>
int main()

{

int a,b;

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

a=a+b;

b=a-b;

a=a-b;

printf("%d %d\n",a,b);

return 0;

}

猜你喜欢

转载自www.cnblogs.com/asher0608/p/11689426.html
今日推荐