Professional Documents
Culture Documents
PROJEKTNI ZADATAK IZ
PROGRAMIRANJA
Zadatak:
-Pomjerati krunicu unutar granica velikog pravougaonika strelicama na tastaturi za
kraj pritisnuti slovo M ?
IZRADA ZADATKA
Rjesenje zadatka:
#include <cstdlib>
#include <iostream>
#include <winbgim.h>
using namespace std;
int main()
{ int x=300, y=300, xp, yp;
initwindow (1000,1000);
char pomjeranje='p';
cleardevice();
while (pomjeranje!='m')
{rectangle(200,200,800,500);
circle (x,y,20);
xp=x; yp=y;
pomjeranje =getch();
if (pomjeranje==75) x=x-5;
if (pomjeranje==77) x=x+5;
if (pomjeranje==72) y=y-5;
if (pomjeranje==80) y=y+5;
if(x>780 || y>480 || x<220 || y<220)
{x=xp; y=yp;}
cleardevice();
}
closegraph();
return EXIT_SUCCESS;
}
initwindow (1000,1000);
(Ubacivanje prozora )
char pomjeranje='p';
cleardevice();
while (pomjeranje!='m')
{rectangle(200,200,800,500);
circle (x,y,20);
xp=x; yp=y;
pomjeranje =getch();
if (pomjeranje==75) x=x-5;
if (pomjeranje==77) x=x+5
if (pomjeranje==72) y=y-5;
if (pomjeranje==80) y=y+5;
{x=xp; y=yp;}
cleardevice();