美国老土真不土,学问肚中涨鼓鼓。改行专业搞科研,育人顺便赚大钱! 这个得赞,大赞!!!有个问题想请教,见内。

本帖于 2019-01-23 18:24:42 时间, 由普通用户 俺老四川哈 编辑

想把x和y换一下, 下面的code哪里有问题,我今天想呀想,嗯, 人老了,就是不行了,只有耍点老得不老的东西。 麻烦代劳。 

#include <stdio.h>  

// This function swaps values of xp and yp
void swap(int xp, int yp)
{
    int temp = xp;
    xp = yp;
    yp = temp;
}
  
int main()
{
    int x, y;
    printf("Enter Value of x ");
    scanf("%d", &x);
    printf("\nEnter Value of y ");
    scanf("%d", &y);
    swap(x, y);
    printf("\nAfter Swapping: x = %d, y = %d";
}

 

 

请您先登陆,再发跟帖!