求一个利用函数来进行交换输入两数的c语言程序

如题所述

#include<stdio.h>


void swap(int* u,int* v);

int main(void)

{

int x=5,y=10;

swap(&x,&y);

printf("x=%d.y=%d\n", x,y);

}


void swap(int * u,int * v)

{

int temp;

temp=*u;

*u=*v;

*v=temp;


}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-11-02
#include <stdio.h>
void swap(int *a, int *b)
{
    int t;
    t = *a, *a = *b, *b = t;
}
int main()
{
    int a, b;
    scanf ("%d%d", &a, &b);
    swap(&a, &b);
    printf ("%d %d\n", a, b);
    return 0;
}

相似回答
大家正在搜