| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 565 人关注过本帖
标题:为什么我的程序在别人的机子上不能运行?
只看楼主 加入收藏
yujia
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-9-24
收藏
 问题点数:0 回复次数:5 
为什么我的程序在别人的机子上不能运行?

我的程序在自己机子上能运行,是用WIN-TC 的编译器,但在别人的机器上却不能实现,只显示编译成功,这是为什么? 谢谢! 下面是程序: #include<stdio.h> #include<math.h> #include<graphics.h> #include<conio.h> #include<dos.h> int movespeed = 2000; void Init( ); /*基本界面*/ void Show( ); /*画塔*/ void DrawPiece(int x, int y, int m, int color);

void main( ) { int a, b; Init( ); Show( );

/* 画出开始形式 */ DrawPiece(150, 350, 1, RED); DrawPiece(150, 330, 2, GREEN); DrawPiece(150, 310, 3, WHITE);

/* 盘子的移动程序 */ for (b=310; b>=120; b=b-2) /* 盘子移到所在塔的上方*/ { delay(movespeed); DrawPiece(150, b, 3, BLACK); /* 察除原来痕迹 */ Show( ); DrawPiece(150, b-2, 3, WHITE); /* 设定新的位置 */ } for (a=150; a<=448; a+=2) /* 移到要到达的塔上方 */ { delay(movespeed); DrawPiece(a, b, 3, BLACK); DrawPiece(a+2, b, 3, WHITE); } for (b=118; b<=348; b=b+2) /* 移入要到达的塔内 */ { delay(movespeed); DrawPiece(a, b, 3, BLACK); Show( ); DrawPiece(a, b+2, 3, WHITE); }

/* 移第二次*/ for (b=330; b>=120; b=b-2) { delay(movespeed); DrawPiece(150, b, 2, BLACK); Show( ); DrawPiece(150, b-2, 2, GREEN); } for (a=150; a<=298; a+=2) { delay(movespeed); DrawPiece(a, b, 2, BLACK); DrawPiece(a+2, b, 2, GREEN); } for (b=118; b<=348; b=b+2) { delay(movespeed); DrawPiece(a, b, 2, BLACK); Show( ); DrawPiece(a, b+2, 2, GREEN); }

/* 移第三次*/ for (b=350; b>=120; b=b-2) { delay(movespeed); DrawPiece(450, b, 3, BLACK); Show( ); DrawPiece(450, b-2, 3, WHITE); } for (a=450; a>=302; a-=2) { delay(movespeed); DrawPiece(a, b, 3, BLACK); DrawPiece(a-2, b, 3, WHITE); } for (b=118; b<=328; b=b+2) { delay(movespeed); DrawPiece(a, b, 3, BLACK); Show( ); DrawPiece(a, b+2, 3, WHITE); }

/* 移第四次*/ for (b=350; b>=120; b=b-2) { delay(movespeed); DrawPiece(150, b, 1, BLACK); Show( ); DrawPiece(150, b-2, 1, RED); } for (a=150; a<=448; a+=2) { delay(movespeed); DrawPiece(a, b, 1, BLACK); DrawPiece(a+2, b, 1, RED); } for (b=118; b<=348; b=b+2) { delay(movespeed); DrawPiece(a, b, 1, BLACK); Show( ); DrawPiece(a, b+2, 1, RED); }

/*移第五次*/ for (b=330; b>=120; b=b-2) { delay(movespeed); DrawPiece(300, b, 3, BLACK); Show( ); DrawPiece(300, b-2, 3, WHITE); } for (a=300; a>=152; a-=2) { delay(movespeed); DrawPiece(a, b, 3, BLACK); DrawPiece(a-2, b, 3, WHITE); } for (b=118; b<=348; b=b+2) { delay(movespeed); DrawPiece(a, b, 3, BLACK); Show( ); DrawPiece(a, b+2, 3, WHITE); }

/* 移第六次*/ for (b=350; b>=120; b=b-2) { delay(movespeed); DrawPiece(300, b, 2, BLACK); Show( ); DrawPiece(300, b-2, 2, GREEN); } for (a=300; a<=448; a+=2) { delay(movespeed); DrawPiece(a, b, 2, BLACK); DrawPiece(a+2, b, 2, GREEN); } for (b=118; b<=328; b=b+2) { delay(movespeed); DrawPiece(a, b, 2, BLACK); Show( ); DrawPiece(a, b+2, 2, GREEN); }

/* 移第七次*/ for (b=350; b>=120; b=b-2) { delay(movespeed); DrawPiece(150, b, 3, BLACK); Show( ); DrawPiece(150, b-2, 3, WHITE); } for (a=150; a<=448; a+=2) { delay(movespeed); DrawPiece(a, b, 3, BLACK); DrawPiece(a+2, b, 3, WHITE); } for (b=118; b<=308; b=b+2) { delay(movespeed); DrawPiece(a, b, 3, BLACK); Show( ); DrawPiece(a, b+2, 3, WHITE); }

getch( ); }

void Init( ) /*基本界面*/ { int driver =DETECT , mode ; initgraph ( & driver , & mode , "c:\\BC31\\BGI\\"); setcolor(BLUE); rectangle(30, 50, 580, 400); gotoxy(100,100); printf("%c---", 2); printf("Welcome to play the HANIO!%c", 2); }

void Show( ) /*画塔*/ { setcolor(RED); line(50, 351, 550, 351); line(150, 150, 150, 350); line(300, 150, 300, 350); line(450, 150, 450, 350); }

void DrawPiece(int x, int y, int m, int color) /*画盘子*/ { switch(m) { case 1: setcolor(color); setfillstyle(SOLID_FILL, color); bar(x-70, y-20, x+70, y); break; case 2: setcolor(color); setfillstyle(SOLID_FILL, color); bar(x-50, y-20, x+50, y); break; case 3: setcolor(color); setfillstyle(SOLID_FILL, color); bar(x-30, y-20, x+30, y); break; } }

搜索更多相关主题的帖子: 运行 
2005-09-24 10:49
gisiyang
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2005-9-18
收藏
得分:0 
我的也可以.

『StarCraft』
2005-09-24 11:13
Knocker
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:10454
专家分:603
注 册:2004-6-1
收藏
得分:0 
置顶贴里找答案。

九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。     -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。   -毛泽东
2005-09-24 11:23
yujia
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-9-24
收藏
得分:0 
谢谢!
2005-09-24 11:37
wxf
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-9-24
收藏
得分:0 
有可能是别人的机子上没有包含graphics.h着个文件
2005-09-24 21:51
029
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2005-8-26
收藏
得分:0 
你在前面加上
int driver=DETECT;gmode;
registerbgidriver(DETECT);
initgraph(&amp;driver,&amp;gmode,"");
ok!

2005-09-26 11:03
快速回复:为什么我的程序在别人的机子上不能运行?
数据加载中...
 
   



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

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