标题:我写了一个程序,大家帮我看看哪里有问题
取消只看楼主
wuzihao
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-11-1
 问题点数:0 回复次数:0 
我写了一个程序,大家帮我看看哪里有问题
// test5.4.cpp : demonstrates passing by value

#include "stdafx.h"
#include "iostream"

using namespace std;
void swap(int x, int y);

int main()
{
    int x = 5,y = 10;

    cout <<"Main.Before swap, x: "<< x <<" y: "<< y << endl;
    swap(x,y);
    cout <<"Main.After swap, x: "<< x <<" y: "<< y << endl;
    return 0;
}

void swap(int x, int y)
{
    int temp;

    cout <<"Swap.Before swap,x: "<< x <<" y: "<< y << endl;

    temp = x;
    x = y;
    y = temp;

    cout <<"Swap.After swap,x: "<< x <<" y: "<< y << endl;
}
搜索更多相关主题的帖子: passing include return 
2008-06-04 11:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-217566-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.158975 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved