gpt4 book ai didi

c - 使用函数 NOT WORKING 在 C 中交换程序

转载 作者:太空宇宙 更新时间:2023-11-04 07:53:31 25 4
gpt4 key购买 nike

<分区>

/输入的数字应该交换和显示。这个简单的程序对我来说看起来不错,但事实并非如此。我试过使用 printf("%d%d") 它有效但在堆栈上使用默认值。但它无法使用此代码。我尝试过不同的编译器,如 TurboC++、CodeBlocks(GCC)。有人可以帮我解释一下吗?提前致谢/

#include <stdio.h>
#include <stdlib.h>
void swap(int,int );
int main()

{
int x,y;
printf("Two Numbers: ");
scanf("%d\n%d",&x,&y);
swap(x,y);
printf("%d%d",x,y);//printf("%d%d"); makes the program work but not genuinely
return 0;
getch();
}
void swap(int x,int y)
{
int temp;
temp=y;
y=x;
x=temp;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com