#include%26lt;graphics.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
int GM,GD=DETECT; int x,a; char l[2], c;
initgraph(%26amp;GD,%26amp;GM," ");
cleardevice();
setfillstyle(10,color);
settextstyle(10,0,12);setbkcolor(color...
circle(320,240,160);
fillellipse(320,240,160,160);
outtextxy(278,80,"3");
getch();
closegraph();
}
this is the program and it works, i run it already but the problem is the number doesn't appear in ramdom position. what's missing on my program? pls help... reply asap..thanks!
How to make program on graphic mode that will appear a random numbers?
Hello,
My C++ is a little rusty but i get the idea of whats going on here.
I think your problem is the line:
outtextxy(278,80,"3");
What this is telling the compiler is, write out the number 3 to the screen at position 278 on the x axis, and 80 on the y axis. What you WANT to do is not say exactly where on the x and y axis but choose random numbers that are within the resolution of the screen.
I can see that you have declared a variable x, which i am assuming is supposed to store the random number representing the x coordinate.
In summation, set x to a random position within the width of the screen, and subtract the width of the number in pixels. Replace the number 278 in the function outtextxy with the variable x.
I hope this makes sense. Best of Luck!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment