Path: blob/main/10. Sunrise and Sunset.cpp
724 views
#include<iostream>1#include<graphics.h>2#include<cstdlib>3#include<dos.h>4#include<cmath>5using namespace std;67int main()8{9initwindow(800,500);10int x0,y0;11int gdriver = DETECT,gmode,errorcode;12int xmax,ymax;1314errorcode=graphresult();1516if(errorcode!=0)17{18cout<<"Graphics error:"<<grapherrormsg(errorcode);19cout<<"Press any ket to halt";20exit(1);21}22int i,j;23setbkcolor(BLUE);24setcolor(RED);25rectangle(0,0,getmaxx(),getmaxy());2627outtextxy(250,240,"::::PRESS ANY KEY TO CONTINUE:::::");28while(!kbhit());29for(i=50,j=0;i<=250,j<=250;i+=5,j+=5)30{31delay(120);32cleardevice();33if(i<=150)34{35setcolor(YELLOW);36setfillstyle(1,YELLOW);37fillellipse(i,300-j,20,20);38}39else40{41setcolor(GREEN^RED);42setfillstyle(1,GREEN^RED);43fillellipse(i,300-j,20,20);44}45}46delay(1000);47cleardevice();48setcolor(RED);49setfillstyle(1,RED);50fillellipse(300,50,20,20);51delay(150);5253int k,l;54for(k=305,l=55;k<=550,l<=300;k+=5,l+=5)55{56delay(120);57cleardevice();58if(k<=450)59{6061setcolor(GREEN^RED);62setfillstyle(1,GREEN^RED);6364fillellipse(k,l,20,20);65}66else67{68setcolor(YELLOW);69setfillstyle(1,YELLOW);70fillellipse(k,l,20,20);71}72}73return 0;74}757677