tc运行程序出错,用vc可以运行 用tc不行
程序如下#include<graphics.h>#include<conio.h>#include<graphics.h>#include<conio.h>#includ...
程序如下#include<graphics.h>#include<conio.h>#include <graphics.h>#include <conio.h>#include <time.h>#define MAXSNOW 500struct SNOW{ double x; int y; double step; int color;};SNOW snow[MAXSNOW];void InitSnow(int i){ snow[i].y = 0; snow[i].x = rand() % 520; snow[i].step = (rand() % 5000) / 1000.0 + 1; snow[i].color = (int)(snow[i].step * 255 / 6.0 + 0.5); snow[i].color = RGB(snow[i].color, snow[i].color, snow[i].color);}void MoveSnow(int i){putpixel((int)snow[i].x, snow[i].y, 0);snow[i].y += snow[i].step; if (snow[i].y > 640) InitSnow(i);putpixel((int)snow[i].x, snow[i].y, snow[i].color);}void FillCircle(int x, int y, int r, COLORREF color){ int tx = 0, ty = r, d = 3 - 2 * r, i; while( tx < ty) { for (i = x - ty; i <= x + ty; i++) {putpixel(i, y - tx, color); if (tx != 0) putpixel(i, y + tx, color);} if (d < 0) d += 4 * tx + 6; else { for (i = x - tx; i <= x + tx; i++) { putpixel(i, y - ty, color); putpixel(i, y + ty, color); } d += 4 * (tx - ty) + 10, ty--; } tx++; } if (tx == ty) for (i = x - ty; i <= x + ty; i++) { putpixel(i, y - tx, color); putpixel(i, y + tx, color); }}void main(){srand((unsigned)time(NULL)); initgraph(640, 480); for(int i = 0; i < MAXSNOW; i++){InitSnow(i); snow[i].y = rand() % 640;}FillCircle(550, 100, 50, YELLOW);FillCircle(500, 100, 65, BLACK);while(!kbhit()){ for(int i = 0; i < MAXSNOW; i++) MoveSnow(i); Sleep(20); } getch(); closegraph();}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询