PDA

View Full Version : سوال: رسم دايره در ++c



pooooneh
جمعه 06 دی 1387, 13:36 عصر
سلام
كسي هست اشكال اين برنامه رو بدونه؟

اين برنامه بايد شماره رنگ مورد نظر وشعاع دايره رو بگيره و مساحت و محيط رو بده ولي براي رنگ جواب نمي ده

#include <graphics.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
class color
{ public:
int type_color;
void coloor(int c) { type_color=c; }
};
class figure:public color
{ protected:
double x,y,mas,moh;
public:
void set(double n , double m=0) { x=n; y=m; }
virtual void show() { cout<<"not"; }
};
class ci:public figure
{
public: void show();
};
void ci::show()
{
gotoxy(5,5); cout << "shoa ra vared konid : ";
cin >> x ;
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
setcolor(type_color);
for (float i = .1 ; i <=x*7 ; i+=.1)
circle(320, 240, i);
mas = x*x*3.14;
char str[20];
moveto(250, 440);
outtext("Masahat = ");
outtext(gcvt(mas, 10 , str));
moh = x*2*3.14;
strcpy(str,"");
moveto(250, 470);
outtext("Mohit = ");
outtext(gcvt(moh, 10 , str));
getch();
closegraph();
};
int main()
{
clrscr();
int a;
double x;
figure *p;
ci c,ob;
cout << "shomare range morede nazar ra vared konid : ";
cin >> a ;
ob.coloor(a);
p=&c;
gotoxy(5,5); cout << "shoa ra vared konid : ";
cin >> x ; p->set(x); p->show();
getch();
return 0;
}