#include<iostream.h>
void main()
{int *a,*b;
int x,y;
int swap(int *m,int* n);
cin>>x;
cin>>y;
a=&x;
b=&y;
swap(a,b);
cout<<*a;
cout<<*b;
}
int swap(int *m,int *n)
{
int *t;
t=m;
m=n;
n=t;
// cout<<*m;
// cout<<*n;
return(*m,*n);
}
类型严重不匹配,指针与int怎么可以赋值???
by 雨中飞燕  QQ:78803110  QQ讨论群:5305909


[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
[url=http://bbs.bc-cn.net/viewthread.php?tid=162918]C++编写的Windows界面游戏[/url]
[url=http://yzfy.org/]C/C++算法习题(OnlineJudge):[/url] http://yzfy.org/
#include <iostream>
using namespace std;
int main()
{
    int* a, * b;
    int x, y, z;
    int swap(int* m, int* n);
    cin >> x;
    cin >> y;
    a = &x;
    b = &y;
    z = swap(a, b);
    cout << * a << endl;
    cout << * b << endl;
cout<<z<<endl;
    return 0;
}
int swap(int* m, int* n)
{
    int t;
    t = * m;
    *m = * n;
    *n = t;
    //    cout<<*m;
    //    cout<<*n;
    return (*m, * n); // returns value of *m. Is this what you want?
}
/**
Hi sister 凌冰月:
read more about passing by value and passing by reference/address.
Output:
5 6
6
5
5
Press any key to continue . . .
*/

#include<iostream.h>
void swap(int *rx,int *ry);
int main()
{
    int x,y;
    cout<<"please enter two number:";
    cin>>x;
    cin>>y;
    cout<<"before the swap...";
    cout<<"x:"<<x<<"y:"<<y<<endl;
    swap(x,y);
    cout<<"after the swap...."
    cout<<"x:"<<x<<"y:"<<y<<endl;
    return 0;
}
void swap(int *rx,int *ry)
{
    int temp;
    temp=*rx;
    *rx=*ry;
    *ry=temp;
}