[C language] job exchange value of the variable

the first method:

#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;
}

The second method:

#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;

}

 

Guess you like

Origin www.cnblogs.com/asher0608/p/11689426.html