void Swap(int *a,int *b)
int *temp; *temp=*a; *a=*b; *b=*temp;
#include <stdio.h>
#include<stdlib.h >
void Swap(int a,intb){
int *temp=(int *)malloc(sizeof(int)*1);
*temp = *a;
*a = *b;
*b= *temp;
}
int main(){
int a=23,b=10;
Swap(&a,&b);
printf("%d,%d",a,b);//10,23
}
要用#include<stdio.h>库。给指针分配内存空间。
void Swap(int *a,int *b)
{
int temp; temp=*a; *a=*b; *b=temp;
}