#1 18.04.07 22:33
Помогите составить программу на Borland C++
Программа состоит в том чтобы изобразить на экране отрезок, который будет вращаться вокруг своей середины и передвигаться по диагонали экрана сверху вниз справа налево, при этом меняя свой цвет с каждым шагом. Должен он пройти только один раз. Надо составить прогу в С++, может кто делал, или че-то похожее на это, или у кого какие мысли умные проснулись, подскажите.
Offline
#2 19.04.07 02:09
Re: Помогите составить программу на Borland C++
вариант.
Код: cpp:
#include <graphics.h> #include <stdio.h> #include <conio.h> #include <math.h> #include <dos.h> #include <stdlib.h> const int length = 15; // pixel const int step = 5; // pixel const int dtime = 100; // msec const int angle = 10; // degree int main() { int gdriver, gmode = DETECT; initgraph( &gdriver, &gmode, "c:\\bc5\\bgi" ); if (grOk != graphresult()) // graphics error { printf( "\nDriver not found! Press key..." ); getch(); return 1; } srand( (unsigned)NULL ); int x0,y0,x1,y1; for(int alpha=0, cX=getmaxx(), cY=0; cX>0; cX-=4*step, cY+=3*step, alpha+=angle) { setcolor( BLACK ); line( x0,y0,x1,y1 ); x0 = cX - sin(alpha)*length; y0 = cY - cos(alpha)*length; x1 = cX + sin(alpha)*length; y1 = cY + cos(alpha)*length; setcolor( rand() % 15 ); line( x0,y0,x1,y1 ); delay( dtime ); } getch(); closegraph(); return 0; }
Исправлено Fatboy (19.04.07 02:12)
Offline

