画图板程序和扫雷游戏
easyx吧
全部回复
仅看楼主
level 9
zhangjb90s 楼主
一楼喂百度
2013年04月08日 06点04分 1
level 9
zhangjb90s 楼主
2013年04月08日 06点04分 2
level 9
zhangjb90s 楼主
2013年04月08日 06点04分 3
2013年07月11日 07点07分
这链接没有了
2013年10月14日 05点10分
level 10
LZ怎么想起问这么深刻的问题了,我想都不去想。。。[汗]
2013年04月08日 09点04分 5
编程的时候突然想到的。。。。
2013年04月08日 09点04分
level 9
zhangjb90s 楼主
另外问一个问题:
定义一个全局变量,假如一个函数内使用该变量,是该以形参传递过去还是在该函数内直接引用?从速度上看,哪种方式比较快?@yangw80
2013年04月08日 10点04分 6
回复 问者86526442 :简单地测试了一下,调用函数次数很大时,还是以“形参传递过去”效率高一点,不过这种测试比较极端,现实中基本不可能
2013年04月13日 02点04分
回复 zhangjb90s :测试的程序在下面,不知道这种测试方法可不可行
2013年04月13日 02点04分
回复 问者86526442 :都需要放入寄存器中,我猜是这样:形参直接给出,而全局变量还要去找
2013年04月13日 23点04分
level 10
顶一顶,做得真不错
2013年04月08日 10点04分 7
level 9
zhangjb90s 楼主
#include <stdio.h>
#include<conio.h>
#include <time.h>
#define N 10
int globle=4;
int func1(void)
{int temp=globle;return temp;}
int func2(int t)
{int temp=t;return temp;}
int main(){
clock_t start,end,evarage;
int local=4;
int i,j,k;
start=clock();
for(j=0;j<N;j++)
for(i=0;i<100000;i++)
{func1();}
end=clock();
printf("globle variable %d %d %d\n",start,end,end-start);
start=clock();
for(j=0;j<N;j++)
for(i=0;i<100000;i++)
{func2(globle);}
end=clock();
printf("local variable %d %d %d\n",start,end,end-start);
getch();
return 0;
}
2013年04月13日 02点04分 9
level 12
全局变量和局部变量哪个快,可以直接看汇编代码。我先把程序简化一下:
#include<conio.h>
int globle=4;
int func1(void)
{
int temp=globle;
return temp;
}
int func2(int t)
{
int temp=t;
return temp;
}
int main()
{
func1();
func2(globle);
return 0;
}
2013年04月15日 07点04分 10
level 12
然后在 vc6 里面编译,按 F10 开始调试,按 Alt + 8 打开汇编窗口。然后就可以找到对应的代码了。
2013年04月15日 07点04分 11
level 12
先看调用的对比:
func1();
004010C8 call @ILT+10(func1) (0040100f)
func2(globle);
004010CD mov eax,[globle (00424a30)]
004010D2 push eax
004010D3 call @ILT+0(func2) (00401005)
004010D8 add esp,4
2013年04月15日 07点04分 12
level 12
再看看函数体的代码:
6: int func1(void)
7: {
00401030 ……
8: int temp=globle;
00401048 mov eax,[globle (00424a30)]
0040104D mov dword ptr [ebp-4],eax
9: return temp;
00401050 mov eax,dword ptr [ebp-4]
10: }
12: int func2(int t)
13: {
00401070 ……
14: int temp=t;
00401088 mov eax,dword ptr [ebp+8]
0040108B mov dword ptr [ebp-4],eax
15: return temp;
0040108E mov eax,dword ptr [ebp-4]
16: }
2013年04月15日 07点04分 13
level 12
快慢问题我也想不通。。。
2013年04月15日 07点04分 14
我的那段测试代码也不行。 如果先调用func1后func2,则结果显示局部变量快。 如果先调用func2后func1,则结果显示全局变量快。 [拍砖]
2013年04月15日 09点04分
回复 zhangjb90s : 所以啊,不要纠结这个问题了,怎么清晰怎么来吧。
2013年04月16日 00点04分
回复 yangw80 :嗯,不纠结了。只是写程序时偶然想到的
2013年04月16日 00点04分
level 14
编的真好,比我那个好多了,谢谢,学习了
2013年04月19日 01点04分 15
level 4
扫雷程序可以再发一下吗?下载不了……
2013年07月11日 15点07分 16
回复 zhangjb90s :多谢啦。C:\Users\lee\Desktop\扫雷\扫雷.cpp(4) : fatal error C1853: 'Release/扫雷.pch' is not a precompiled header file created with this compiler 下载下来出现这个问题怎么解决?
2013年07月11日 15点07分
回复 摇杆小飞机 :把Release文件夹删除试一下,我这边用vc6.0重新编译了一下,没什么问题
2013年07月12日 00点07分
level 1
能不能再给我发一个画图板的程序了,多谢了!!![揪耳朵]!
我邮箱是[email protected],真的非常感谢。
2013年10月28日 13点10分 17
1