一个简单的C程序

[复制链接]
查看11 | 回复4 | 2011-3-13 15:50:27 | 显示全部楼层 |阅读模式
#include /*********found**********/void fun(int& a,int& b ){int t;/*********found**********/t=a;a=b;b=t;}void main(){int a,b;a=8;b=3;fun(a,b);printf("%d,%d\n",a,b);};...
回复

使用道具 举报

千问 | 2011-3-13 15:50:27 | 显示全部楼层
void fun(int a,int b )不带返回值,形参与实参不是同一个变量,main函数输出的是做实参的a,b;函数调位的是形参a,b。所以无结果了。我喜欢的一种方式是在void fun(int a,int b )中输出。#include /*********found**********/void fun(int a...
回复

使用道具 举报

千问 | 2011-3-13 15:50:27 | 显示全部楼层
void fun(int& a,int& b )...
回复

使用道具 举报

千问 | 2011-3-13 15:50:27 | 显示全部楼层
c交换两个变量的值应该用指针改成#include /*********found**********/void fun(int *a,int *b ){int t;/*********found**********/t=*a;*a=*b;*b=t;}main(){int a...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行