,求解决一下这个程序有什么问题?
#include
void swap(int a,int b);
int main()
{
int a,b;
scanf("%d %d",&a,&b);
swap(a,b);
return 0;
void swap(int a,int b)
{
int t;
a=t;
a=b;
b=t;
printf("%d %d",a,b);
}
}
E:\C语言练习\collect2.exe [Error] ld returned 1 exit status
E:\C语言练习\collect2.exe [Error] ld returned 1 exit status
你的意思想让A和b交换的思想吧,
格式有误
int t=a
a=b
b=t,
报错原因,你把未定义的t给了a,又给了b,系统不知道这是一个什么书
你贴出来的代码也不全,我也不懂哪报错,我按照你的想法修改了
#include <stdio.h>
void swap(int a,int b);
int main() {
int a, b;
scanf("%d %d", &a, &b);
swap(a, b);
return 0;
}
void swap(int a,int b)
{
int t;
t=a;
a=b;
b=t;
printf("%d %d",a,b);
}