当前位置: 代码迷 >> C语言 >> 为什么我的程序在别人的机子上不能运行?
  详细解决方案

为什么我的程序在别人的机子上不能运行?

热度:301   发布时间:2005-09-24 10:49:00.0
为什么我的程序在别人的机子上不能运行?

我的程序在自己机子上能运行,是用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; } }

搜索更多相关的解决方案: 运行  

----------------解决方案--------------------------------------------------------
我的也可以.
----------------解决方案--------------------------------------------------------
置顶贴里找答案。
----------------解决方案--------------------------------------------------------
谢谢!
----------------解决方案--------------------------------------------------------
有可能是别人的机子上没有包含graphics.h着个文件
----------------解决方案--------------------------------------------------------
你在前面加上
int driver=DETECT;gmode;
registerbgidriver(DETECT);
initgraph(&amp;driver,&amp;gmode,"");
ok!
----------------解决方案--------------------------------------------------------
  相关解决方案