鱼C论坛

 找回密码
 立即注册
查看: 1454|回复: 1

请问以下程序如何拯救?

[复制链接]
发表于 2019-3-5 22:19:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include <iostream>
#include <cmath>
#include <windows.h>
#include <stdio.h >
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void DDAline(int x0,int y0,int x1,int y1)
{
  int     dx,dy,eps1,k;
  float  x,y,xIncre,yIncre;
  dx=x1-x0; dy=y1-y0;
  x=x0;         y=y0;
  if (abs(dx)>abs(dy)) eps1=abs(dx);
  else eps1=abs(dy);
  xIncre=(float)dx/(float)eps1;
  yIncre=(float)dy/(float)eps1;
  for (k=0;k<=eps1;k++) {
   putpixel((int)(x+0.5),(int)(y+0.5));
   x+=xIncre;
   y+=yIncre;
   }
}
int main(int argc, char** argv) {
       
        return 0;
}

报错地方在putpixel这个函数。putpixel这个函数需要什么头文件

网上说的graphics.h这个头文件 C++报错。。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-3-5 23:22:26 | 显示全部楼层
本帖最后由 jackz007 于 2019-3-5 23:33 编辑

    Turbo C 2.0 听说过吧,试试这个 graphics.h
  1. /*        graphics.h

  2.         Definitions for Graphics Package.

  3.         Copyright (c) Borland International 1987,1988
  4.         All Rights Reserved.
  5. */

  6. #if __STDC__
  7. #define _Cdecl
  8. #else
  9. #define _Cdecl        cdecl
  10. #endif

  11. #if     !defined(__GRAPHX_DEF_)
  12. #define __GRAPHX_DEF_

  13. enum graphics_errors {                /* graphresult error return codes */
  14.         grOk                   =   0,
  15.         grNoInitGraph           =  -1,
  16.         grNotDetected           =  -2,
  17.         grFileNotFound           =  -3,
  18.         grInvalidDriver    =  -4,
  19.         grNoLoadMem           =  -5,
  20.         grNoScanMem           =  -6,
  21.         grNoFloodMem           =  -7,
  22.         grFontNotFound           =  -8,
  23.         grNoFontMem           =  -9,
  24.         grInvalidMode           = -10,
  25.         grError            = -11,   /* generic error */
  26.         grIOerror           = -12,
  27.         grInvalidFont           = -13,
  28.         grInvalidFontNum   = -14,
  29.         grInvalidVersion   = -18
  30. };

  31. enum graphics_drivers {         /* define graphics drivers */
  32.         DETECT,                 /* requests autodetection */
  33.         CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514,        /* 1 - 6 */
  34.         HERCMONO, ATT400, VGA, PC3270,                        /* 7 - 10 */
  35.         CURRENT_DRIVER = -1
  36. };

  37. enum graphics_modes {                /* graphics modes for each driver */
  38.     CGAC0      = 0,  /* 320x200 palette 0; 1 page        */
  39.     CGAC1      = 1,  /* 320x200 palette 1; 1 page        */
  40.     CGAC2      = 2,  /* 320x200 palette 2: 1 page        */
  41.     CGAC3      = 3,  /* 320x200 palette 3; 1 page        */
  42.     CGAHI      = 4,  /* 640x200 1 page                        */
  43.     MCGAC0     = 0,  /* 320x200 palette 0; 1 page        */
  44.     MCGAC1     = 1,  /* 320x200 palette 1; 1 page        */
  45.     MCGAC2     = 2,  /* 320x200 palette 2; 1 page        */
  46.     MCGAC3     = 3,  /* 320x200 palette 3; 1 page        */
  47.     MCGAMED    = 4,  /* 640x200 1 page                        */
  48.     MCGAHI     = 5,  /* 640x480 1 page                        */
  49.     EGALO      = 0,  /* 640x200 16 color 4 pages        */
  50.     EGAHI      = 1,  /* 640x350 16 color 2 pages        */
  51.     EGA64LO    = 0,  /* 640x200 16 color 1 page         */
  52.     EGA64HI    = 1,  /* 640x350 4 color  1 page         */
  53.     EGAMONOHI  = 0,  /* 640x350 64K on card, 1 page - 256K on card, 4 pages */
  54.     HERCMONOHI = 0,  /* 720x348 2 pages                 */
  55.     ATT400C0   = 0,  /* 320x200 palette 0; 1 page        */
  56.     ATT400C1   = 1,  /* 320x200 palette 1; 1 page        */
  57.     ATT400C2   = 2,  /* 320x200 palette 2; 1 page        */
  58.     ATT400C3   = 3,  /* 320x200 palette 3; 1 page        */
  59.     ATT400MED  = 4,  /* 640x200 1 page                        */
  60.     ATT400HI   = 5,  /* 640x400 1 page                        */
  61.     VGALO      = 0,  /* 640x200 16 color 4 pages        */
  62.     VGAMED     = 1,  /* 640x350 16 color 2 pages        */
  63.     VGAHI      = 2,  /* 640x480 16 color 1 page         */
  64.     PC3270HI   = 0,  /* 720x350 1 page                        */
  65.     IBM8514LO  = 0,  /* 640x480 256 colors                */
  66.     IBM8514HI  = 1   /*1024x768 256 colors                */
  67. };

  68. /* Colors for setpalette and setallpalette */

  69. #if        !defined(__COLORS)
  70. #define __COLORS

  71. enum COLORS {
  72.     BLACK,                    /* dark colors */
  73.     BLUE,
  74.     GREEN,
  75.     CYAN,
  76.     RED,
  77.     MAGENTA,
  78.     BROWN,
  79.     LIGHTGRAY,
  80.     DARKGRAY,                    /* light colors */
  81.     LIGHTBLUE,
  82.     LIGHTGREEN,
  83.     LIGHTCYAN,
  84.     LIGHTRED,
  85.     LIGHTMAGENTA,
  86.     YELLOW,
  87.     WHITE
  88. };
  89. #endif

  90. enum CGA_COLORS {
  91.     CGA_LIGHTGREEN     = 1,                /* Palette C0 Color Names        */
  92.     CGA_LIGHTRED       = 2,
  93.     CGA_YELLOW               = 3,

  94.     CGA_LIGHTCYAN      = 1,                /* Palette C1 Color Names        */
  95.     CGA_LIGHTMAGENTA   = 2,
  96.     CGA_WHITE               = 3,

  97.     CGA_GREEN               = 1,                /* Palette C2 Color Names        */
  98.     CGA_RED               = 2,
  99.     CGA_BROWN               = 3,

  100.     CGA_CYAN               = 1,                /* Palette C3 Color Names        */
  101.     CGA_MAGENTA        = 2,
  102.     CGA_LIGHTGRAY      = 3
  103. };


  104. enum EGA_COLORS {
  105.     EGA_BLACK                 =  0,            /* dark colors */
  106.     EGA_BLUE                 =  1,
  107.     EGA_GREEN                 =  2,
  108.     EGA_CYAN                 =  3,
  109.     EGA_RED                 =  4,
  110.     EGA_MAGENTA          =  5,
  111.     EGA_BROWN                 =  20,
  112.     EGA_LIGHTGRAY         =  7,
  113.     EGA_DARKGRAY         =  56,     /* light colors */
  114.     EGA_LIGHTBLUE         =  57,
  115.     EGA_LIGHTGREEN         =  58,
  116.     EGA_LIGHTCYAN         =  59,
  117.     EGA_LIGHTRED         =  60,
  118.     EGA_LIGHTMAGENTA         =  61,
  119.     EGA_YELLOW                 =  62,
  120.     EGA_WHITE                 =  63
  121. };

  122. enum line_styles {                /* Line styles for get/setlinestyle */
  123.         SOLID_LINE   = 0,
  124.         DOTTED_LINE  = 1,
  125.         CENTER_LINE  = 2,
  126.         DASHED_LINE  = 3,
  127.         USERBIT_LINE = 4,        /* User defined line style */
  128. };

  129. enum line_widths {                /* Line widths for get/setlinestyle */
  130.         NORM_WIDTH  = 1,
  131.         THICK_WIDTH = 3,
  132. };

  133. enum font_names {
  134.         DEFAULT_FONT        = 0,        /* 8x8 bit mapped font */
  135.         TRIPLEX_FONT        = 1,        /* "Stroked" fonts */
  136.         SMALL_FONT        = 2,
  137.         SANS_SERIF_FONT = 3,
  138.         GOTHIC_FONT        = 4
  139. };

  140. #define HORIZ_DIR        0        /* left to right */
  141. #define VERT_DIR        1        /* bottom to top */

  142. #define USER_CHAR_SIZE        0        /* user-defined char size */

  143. enum fill_patterns {                /* Fill patterns for get/setfillstyle */
  144.         EMPTY_FILL,                /* fills area in background color */
  145.         SOLID_FILL,                /* fills area in solid fill color */
  146.         LINE_FILL,                /* --- fill */
  147.         LTSLASH_FILL,                /* /// fill */
  148.         SLASH_FILL,                /* /// fill with thick lines */
  149.         BKSLASH_FILL,                /* \\\ fill with thick lines */
  150.         LTBKSLASH_FILL,         /* \\\ fill */
  151.         HATCH_FILL,                /* light hatch fill */
  152.         XHATCH_FILL,                /* heavy cross hatch fill */
  153.         INTERLEAVE_FILL,        /* interleaving line fill */
  154.         WIDE_DOT_FILL,                /* Widely spaced dot fill */
  155.         CLOSE_DOT_FILL,         /* Closely spaced dot fill */
  156.         USER_FILL                /* user defined fill */
  157. };

  158. enum putimage_ops {                /* BitBlt operators for putimage */
  159.         COPY_PUT,                /* MOV */
  160.         XOR_PUT,                /* XOR */
  161.         OR_PUT,                 /* OR  */
  162.         AND_PUT,                /* AND */
  163.         NOT_PUT                 /* NOT */
  164. };

  165. enum text_just {                /* Horizontal and vertical justification
  166.                                    for settextjustify */
  167.         LEFT_TEXT        = 0,
  168.         CENTER_TEXT        = 1,
  169.         RIGHT_TEXT        = 2,

  170.         BOTTOM_TEXT        = 0,
  171.      /* CENTER_TEXT        = 1,  already defined above */
  172.         TOP_TEXT        = 2
  173. };


  174. #define MAXCOLORS 15

  175. struct palettetype {
  176.         unsigned char size;
  177.         signed char colors[MAXCOLORS+1];
  178. };

  179. struct linesettingstype {
  180.         int linestyle;
  181.         unsigned upattern;
  182.         int thickness;
  183. };

  184. struct textsettingstype {
  185.         int font;
  186.         int direction;
  187.         int charsize;
  188.         int horiz;
  189.         int vert;
  190. };

  191. struct fillsettingstype {
  192.         int pattern;
  193.         int color;
  194. };

  195. struct pointtype {
  196.         int x, y;
  197. };

  198. struct viewporttype {
  199.         int left, top, right, bottom;
  200.         int clip;
  201. };

  202. struct arccoordstype {
  203.         int x, y;
  204.         int xstart, ystart, xend, yend;
  205. };

  206. void           far _Cdecl arc(int x, int y, int stangle, int endangle,
  207.                           int radius);
  208. void           far _Cdecl bar(int left, int top, int right, int bottom);
  209. void           far _Cdecl bar3d(int left, int top, int right, int bottom,
  210.                             int depth, int topflag);
  211. void           far _Cdecl circle(int x, int y, int radius);
  212. void           far _Cdecl cleardevice(void);
  213. void           far _Cdecl clearviewport(void);
  214. void           far _Cdecl closegraph(void);
  215. void           far _Cdecl detectgraph(int far *graphdriver,int far *graphmode);
  216. void           far _Cdecl drawpoly(int numpoints, int far *polypoints);
  217. void           far _Cdecl ellipse(int x, int y, int stangle, int endangle,
  218.                               int xradius, int yradius);
  219. void           far _Cdecl fillellipse( int x, int y, int xradius, int yradius );
  220. void           far _Cdecl fillpoly(int numpoints, int far *polypoints);
  221. void           far _Cdecl floodfill(int x, int y, int border);
  222. void           far _Cdecl getarccoords(struct arccoordstype far *arccoords);
  223. void           far _Cdecl getaspectratio(int far *xasp, int far *yasp);
  224. int           far _Cdecl getbkcolor(void);
  225. int           far _Cdecl getcolor(void);
  226. struct palettetype * far _Cdecl getdefaultpalette( void );
  227. char *           far _Cdecl getdrivername( void );
  228. void           far _Cdecl getfillpattern(char far *pattern);
  229. void           far _Cdecl getfillsettings(struct fillsettingstype far *fillinfo);
  230. int           far _Cdecl getgraphmode(void);
  231. void           far _Cdecl getimage(int left, int top, int right, int bottom,
  232.                                void far *bitmap);
  233. void           far _Cdecl getlinesettings(struct linesettingstype far *lineinfo);
  234. int           far _Cdecl getmaxcolor(void);
  235. int           far _Cdecl getmaxmode(void);
  236. int           far _Cdecl getmaxx(void);
  237. int           far _Cdecl getmaxy(void);
  238. char *           far _Cdecl getmodename( int mode_number );
  239. void           far _Cdecl getmoderange(int graphdriver, int far *lomode,
  240.                                    int far *himode);
  241. unsigned   far _Cdecl getpixel(int x, int y);
  242. void           far _Cdecl getpalette(struct palettetype far *palette);
  243. int           far _Cdecl getpalettesize( void );
  244. void           far _Cdecl gettextsettings(struct textsettingstype far *texttypeinfo);
  245. void           far _Cdecl getviewsettings(struct viewporttype far *viewport);
  246. int           far _Cdecl getx(void);
  247. int           far _Cdecl gety(void);
  248. void           far _Cdecl graphdefaults(void);
  249. char *           far _Cdecl grapherrormsg(int errorcode);
  250. void           far _Cdecl _graphfreemem(void far *ptr, unsigned size);
  251. void far * far _Cdecl _graphgetmem(unsigned size);
  252. int           far _Cdecl graphresult(void);
  253. unsigned   far _Cdecl imagesize(int left, int top, int right, int bottom);
  254. void           far _Cdecl initgraph(int  far *graphdriver,
  255.                                 int  far *graphmode,
  256.                                 char far *pathtodriver);
  257. int           far _Cdecl installuserdriver( char far *name, int huge (*detect)(void) );
  258. int           far _Cdecl installuserfont( char far *name );
  259. void           far _Cdecl line(int x1, int y1, int x2, int y2);
  260. void           far _Cdecl linerel(int dx, int dy);
  261. void           far _Cdecl lineto(int x, int y);
  262. void           far _Cdecl moverel(int dx, int dy);
  263. void           far _Cdecl moveto(int x, int y);
  264. void           far _Cdecl outtext(char far *textstring);
  265. void           far _Cdecl outtextxy(int x, int y, char far *textstring);
  266. void           far _Cdecl pieslice(int x, int y, int stangle, int endangle,
  267.                                int radius);
  268. void           far _Cdecl putimage(int left, int top, void far *bitmap, int op);
  269. void           far _Cdecl putpixel(int x, int y, int color);
  270. void           far _Cdecl rectangle(int left, int top, int right, int bottom);
  271. void           far _Cdecl restorecrtmode(void);
  272. void           far _Cdecl sector( int X, int Y, int StAngle, int EndAngle,
  273.                               int XRadius, int YRadius );
  274. void           far _Cdecl setactivepage(int page);
  275. void           far _Cdecl setallpalette(struct palettetype far *palette);
  276. void           far _Cdecl setaspectratio( int xasp, int yasp );
  277. void           far _Cdecl setbkcolor(int color);
  278. void           far _Cdecl setcolor(int color);
  279. void           far _Cdecl setfillpattern(char far *upattern, int color);
  280. void           far _Cdecl setfillstyle(int pattern, int color);
  281. unsigned   far _Cdecl setgraphbufsize(unsigned bufsize);
  282. void           far _Cdecl setgraphmode(int mode);
  283. void           far _Cdecl setlinestyle(int linestyle, unsigned upattern,
  284.                                    int thickness);
  285. void           far _Cdecl setpalette(int colornum, int color);
  286. void           far _Cdecl setrgbpalette(int colornum,
  287.                                     int red, int green, int blue);
  288. void           far _Cdecl settextjustify(int horiz, int vert);
  289. void           far _Cdecl settextstyle(int font, int direction, int charsize);
  290. void           far _Cdecl setusercharsize(int multx, int divx,
  291.                                       int multy, int divy);
  292. void           far _Cdecl setviewport(int left, int top, int right, int bottom,
  293.                                   int clip);
  294. void           far _Cdecl setvisualpage(int page);
  295. void           far _Cdecl setwritemode( int mode );
  296. int           far _Cdecl textheight(char far *textstring);
  297. int           far _Cdecl textwidth(char far *textstring);

  298. /***** graphics drivers *****/

  299. int               _Cdecl registerbgidriver(void (*driver)(void));
  300. int           far _Cdecl registerfarbgidriver(void far *driver);

  301. /* !!             These "functions" are NOT user-callable          !! */
  302. /* !! They are there just so you can link in graphics drivers !! */

  303. void               _Cdecl CGA_driver(void);
  304. void               _Cdecl EGAVGA_driver(void);
  305. void               _Cdecl IBM8514_driver(void);
  306. void               _Cdecl Herc_driver(void);
  307. void               _Cdecl ATT_driver(void);
  308. void               _Cdecl PC3270_driver(void);

  309. extern int far _Cdecl CGA_driver_far[];
  310. extern int far _Cdecl EGAVGA_driver_far[];
  311. extern int far _Cdecl IBM8514_driver_far[];
  312. extern int far _Cdecl Herc_driver_far[];
  313. extern int far _Cdecl ATT_driver_far[];
  314. extern int far _Cdecl PC3270_driver_far[];


  315. /***** graphics fonts *****/

  316. int               _Cdecl registerbgifont(void (*font)(void));
  317. int           far _Cdecl registerfarbgifont(void far *font);

  318. /* !!        These "functions" are NOT user-callable,   !! */
  319. /* !! they are there just so you can link in fonts !! */

  320. void               _Cdecl        triplex_font(void);
  321. void               _Cdecl          small_font(void);
  322. void               _Cdecl sansserif_font(void);
  323. void               _Cdecl         gothic_font(void);

  324. extern int far _Cdecl        triplex_font_far[];
  325. extern int far _Cdecl          small_font_far[];
  326. extern int far _Cdecl sansserif_font_far[];
  327. extern int far _Cdecl         gothic_font_far[];


  328. #endif
  329. 
复制代码


      但是,只是有了这个文件似乎并不解决问题,还得要有配套的库文件才可以,所以,如果要试,就下载一个 Turbo C 2.0 编译试试看。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-17 08:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表