为什么显示(#include "graphics.h")此行出错!!!

zxremail 2005-12-19 03:02:07
此程序出自他人之手
我每次在vc++6.0下调试都说不包含graphics.h头文件!!!

-----------------------------------------------------------------------------------------

/* 学习c一段时间了,这却是第一次自己尝试着设计和编写程序,挺过瘾。不过由于时间和功力有限,程序中的问题肯定很多,希望各位大侠多多指出,这里谢过了。另外,有一问题请教,就是现在程序只能做到让礼花一个一个的盛开,能不能想个办法,让礼花以随机的个数,后者说是参差不齐的盛开?



注:程序运行后出现封面,不要按键,过片刻就会进入礼花程序。*/

#include "Conio.h"

#include "graphics.h"

#include "stdio.h"

#include "stdlib.h"

#include "bios.h"

#include "math.h"

struct cir /*存放礼花的位置*/

{

int x;

int y;

}place;

void initgr(void) /* BGI初始化 */

{

int gd=DETECT,gm=0;

initgraph(&gd,&gm,"");

}

void up() /*礼花炮上升*/

{ int aimy;

randomize();

place.x=random(440)+100; /*设定礼花的范围*/

place.y=470;

aimy=random(300)+60;

setlinestyle(0,0,1);

setcolor(WHITE);

circle(place.x,place.y,3);

while(place.y!=aimy) /*礼花的上升过程*/

{

setcolor(BLACK);

circle(place.x,place.y,3);

place.y--;

setcolor(WHITE);

circle(place.x,place.y,3);

delay(1000);

}



setcolor(BLACK);

circle(place.x,place.y,3);

}

shan() /*礼花形状一*/

{

int j,n1,x,t1=1,y;

int p_color;

for(j=0;j<400;j++)

{

n1=rand()%2;

t1=pow(-1,n1);

x=place.x+t1*(rand()%100);

n1=rand()%2;

t1=pow(-1,n1);

y=place.y+t1*(rand()%100);

if(x<35) x=35; /*限制礼花越过窗体*/

if(x>getmaxx()-35) x=getmaxx()-35;

if(y<5) y=5;

p_color=rand()%15;

setlinestyle(0,0,3);

setcolor(p_color);

line(place.x,place.y,x,y);

delay(1000);

setcolor(BLACK);

line(place.x,place.y,x,y);

}

}

ceng() /*礼花形状二*/

{

float x,y,r;

int i;

int c_color;

float k;

k=2*3.14/60;

for(r=10;r<100;r++)

{

for(i=0;i<60;i++)

{

x=r*sin(k*i)+place.x;

y=r*cos(k*i)+place.y;

if(x<35) x=35;

if(x>getmaxx()-35) x=getmaxx()-35;

if(y<5) y=5;

c_color=rand()%15;

putpixel(x,y,c_color);

delay(80);

}



}

for(r=10;r<100;r++)

{

for(i=0;i<60;i++)

{

x=r*sin(k*i)+place.x;

y=r*cos(k*i)+place.y;

if(x<35) x=35;

if(x>getmaxx()-35) x=getmaxx()-35;

if(y<5) y=5;

putpixel(x,y,BLACK);

delay(60);

}



}

}

dian() /*礼花形状三*/

{

int i,j,r;

float x[500],y[500];

float k;

int c_color;

k=2*3.14/60;

for(j=0;j<500;j++)

{

i=rand()%60;

r=rand()%100;

x[j]=r*sin(k*i)+place.x;

y[j]=r*cos(k*i)+place.y;

if(x[j]<35) x[j]=35;

if(x[j]>getmaxx()-35) x[j]=getmaxx()-35;

if(y[j]<5) y[j]=5;

c_color=rand()%15;

setcolor(c_color);

circle(x[j],y[j],1);

delay(1500);

}

for(j=0;j<500;j++)

{

setcolor(BLACK);

circle(x[j],y[j],1);

}

}

void bomb() /*礼花盛开*/

{

int r1,i,n,t=1,q=1,k=1;

int pointX,pointY,point_color;

setcolor(YELLOW);

/*-------------这个过程模拟礼花爆炸瞬间的状态-----------------*/

for(r1=1;r1<=4;r1++)

{

circle(place.x,place.y,r1);

delay(1000);

}

delay(3000);

setcolor(RED);

for(r1=4;r1<=6;r1++)

{

circle(place.x,place.y,r1);

delay(1000);

}

delay(3000);

setcolor(BLACK);

for(r1=6;r1>=1;r1--)

{

circle(place.x,place.y,r1);

delay(1000);

}

for(i=1;i<=20;i++)

{

point_color=rand()%15;

n=rand()%2;

t=pow(-1,n);

pointX=(t*(rand()%6)+place.x);

n=rand()%2;

t=pow(-1,n);

pointY=(t*(rand()%6)+place.y);

putpixel(pointX,pointY,point_color);

delay(2000);

putpixel(pointX,pointY,BLACK);

}

/*----------------------------------------*/

n=rand()%3;

switch(n) /*随机盛开不同的厉害*/

{

case 0:

shan(); break;

case 1:

ceng(); break;

case 2:

dian(); break;

default:

break;

}

}

fengmian() /*封面程序*/

{

int i,j=0;

while(1) /**/

{

settextstyle(0,0,4); /*设置文字输出模式*/



for(i=1;i<=15;i++)

{

setcolor(i);

outtextxy(100,180,"HAPPY NEW YEAR"); /*新年快乐*/

delay(10000);

}

j++;

if(j>5) break;

}

cleardevice();

}

main()

{

initgr();

fengmian();

setbkcolor(BLACK); /*绘制窗体*/

setcolor(YELLOW);

setfillstyle(SOLID_FILL,9);

rectangle(0,0,getmaxx(),getmaxy());

rectangle(1,1,getmaxx()-1,getmaxy()-1);

rectangle(2,2,30,getmaxy()-2);

rectangle(getmaxx()-32,2,getmaxx()-2,getmaxy()-2);

while(!kbhit()) /*进入礼花程序*/

{

up();

bomb();

}

getch();

closegraph();

}
...全文
2201 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
loveliu0429 2005-12-24
  • 打赏
  • 举报
回复
显然是TC嘛
VC不支持该文件的
菜牛 2005-12-24
  • 打赏
  • 举报
回复
显然是TC下面的代码。
loveghb 2005-12-24
  • 打赏
  • 举报
回复
哈,那个头文件是BGI的,VC当然没有了
自己调DOS中断写个算了
rick29 2005-12-23
  • 打赏
  • 举报
回复
vc里没有graphics.h,是TC里的。
早期版本的MSC里(是MSC,不是MSVC),有graph.h库,但其中的绘图函数与TC的graphics.h有很大出入,完全不兼容。后来的VC中,没有这个库了。
bobob 2005-12-23
  • 打赏
  • 举报
回复
graphics.h是tc里面自己实现的图形库,并不是标准图形库头文件,也不是ms支持的,所以在vc里面无法编译通过

也就是说,这个程序不改写的话只能在tc上编译
happyness44 2005-12-23
  • 打赏
  • 举报
回复
抢分
skyphantom 2005-12-19
  • 打赏
  • 举报
回复
呵呵,我刚学VC时碰到的问题,现在出现了。
VC里面没有这个头文件。
找个包含这个头文件的编译器,正确设置环境变量,应该没问题。
我想我是人 2005-12-19
  • 打赏
  • 举报
回复
VC中没有graphics.h头文件,这是TC中特有的!


可是TC又指出以下头文件没有!!!
#include "stdio.h"

#include "stdlib.h"

#include "bios.h"

#include "math.h"



那是你没有将TC正确设置

在WIN9X/2000下使用,先建立X:\TURBOC2\TC.EXE文件的DOS快捷方式,再用鼠标右击该快捷方式,在弹出的环境菜单中选 "属性" 项,在属性对话框中 "程序" 项中可设置工作目录,在 屏幕 项中可设置全屏或窗口方式。然后双击TC快捷方式即可运行了。

这时应注意输出文件夹,建议建一个工作目录 如X:\TCWORK 之类, 这样你的输出文件就不会和TC2文件混在一起了。然后按 Alt+Option 在Directriest选项中更改Output项
__________________ 2005-12-19
  • 打赏
  • 举报
回复
嗨。这不简单。说明graphics.h是原作者自己写得呗。哈~哈~哈.....哈~哈~哈....。
要不就是用了什么第三方的图形库里面的graphics.h。
你别说。看代码还真像是TC的源码。哈。一定比较好玩。
zxremail 2005-12-19
  • 打赏
  • 举报
回复
可是TC又指出以下头文件没有!!!
#include "stdio.h"

#include "stdlib.h"

#include "bios.h"

#include "math.h"


Seu_why 2005-12-19
  • 打赏
  • 举报
回复
TC 里面运行试试
VC不会得到正确结果
ming6424 2005-12-19
  • 打赏
  • 举报
回复
那个头文件好像是turbo c还是borland c++的
VC里面没有这个文件

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧