#include
int main()
{
int x;
int y;
int temp;
scanf("%d,%d",&x,&y);
temp=x;
x=y;
y=temp;
printf("x=%d,y=%d",x,y);
getchar();
return 0;
}
定义第三个变量,然后进行交换就可以了
c语言
#include
main( )
{
int a,b,c;
printf("please input two number a,b:");
scanf("%d,%d",&a,&b);
c=a;
a=b;
b=c;
printf("a=%d,b=%d",a,b);
return 0
}