C语言出现问题:error C2664: 'swap2' : cannot convert parameter 1 from 'int' to 'int *'
#include<stdio.h>voidswap1(intx,inty);voidswap2(int*x,int*y);intmain(){inta,b;printf(...
#include<stdio.h>
void swap1(int x,int y);
void swap2(int *x,int *y);
int main()
{
int a,b;
printf("please input a=:");
scanf("%d",&a);
printf("\n b=:");
scanf("%d",&b);
swap1(a,b);
printf("\nAfter call swap1:a=%d,b=%d\n",a,b);
swap2(a,b);
printf("\nAfter Call swap2:a=%d b=%d\n",a,b);
return 0;
}
void swap1(int x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
}
void swap2(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
} 展开
void swap1(int x,int y);
void swap2(int *x,int *y);
int main()
{
int a,b;
printf("please input a=:");
scanf("%d",&a);
printf("\n b=:");
scanf("%d",&b);
swap1(a,b);
printf("\nAfter call swap1:a=%d,b=%d\n",a,b);
swap2(a,b);
printf("\nAfter Call swap2:a=%d b=%d\n",a,b);
return 0;
}
void swap1(int x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
}
void swap2(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询