| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 362 人关注过本帖
标题:我这样写对吗?
只看楼主 加入收藏
aemig
Rank: 1
等 级:新手上路
帖 子:8
专家分:2
注 册:2010-10-26
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:5 
我这样写对吗?
在自定义函数中使用static静态局部整形变量 计算3的立方!

#include<stdio.h>
void Caculate()
{
     int iInt=3;
     iInt=iInt*3;
     printf("%d/n"iInt);
     return 0;
}
int main()
{
     Caculate();
     printf(结果为:);
     Caculate();
     return 0;
}
搜索更多相关主题的帖子: return 
2010-11-03 09:36
aemig
Rank: 1
等 级:新手上路
帖 子:8
专家分:2
注 册:2010-10-26
收藏
得分:0 
自己拿分先!
2010-11-03 09:38
帝国
Rank: 3Rank: 3
来 自:云南昆明
等 级:论坛游侠
帖 子:68
专家分:144
注 册:2010-10-11
收藏
得分:6 
1、没看到有静态变量
2、自定义函数使用void修饰,但是又提供了返回值,很矛盾啊
3、匈牙利命名法,不喜欢
4、同一个函数调用了2次,我没有看到其意义。
2010-11-03 09:42
aemig
Rank: 1
等 级:新手上路
帖 子:8
专家分:2
注 册:2010-10-26
收藏
得分:0 
#include<stdio.h>
void Caculate()
{
     int iSum=3;
     iSum=iSum*3;
     printf("%d/n"iSum);
}
int main()
{
     Caculate();
     printf(结果为:);
     Caculate();
     return 0;
}


我改了一下!
2010-11-03 09:49
浩凡儿
Rank: 5Rank: 5
等 级:职业侠客
威 望:1
帖 子:101
专家分:394
注 册:2010-10-30
收藏
得分:6 
#include<stdio.h>
void Caculate()
{
    static  iInt=3;
     iInt=iInt*3;
     printf("%d\n",iInt);
     return ;
}
int main()
{
     Caculate();
     printf("结果为:\n");
     Caculate();
     return 0;
} 这就可以了
2010-11-03 12:33
五当家
Rank: 12Rank: 12Rank: 12
等 级:火箭侠
威 望:2
帖 子:1112
专家分:3674
注 册:2010-10-20
收藏
得分:6 
#include<stdio.h>
void Caculate()
{
     static iInt=3;
     iInt=iInt*3;
     printf("%d\n",iInt);
   
}
int main()
{
     printf("结果为:");
     Caculate();
     return 0;
}         你试试。

经验积累中............
2010-11-03 12:42
快速回复:我这样写对吗?
数据加载中...
 
   



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

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