PDA

View Full Version : رسم دایره با یک کاراکتر خاص



shahmohammadi
دوشنبه 18 اسفند 1393, 20:47 عصر
سلام. این کد رو خیلی وقت پیش نوشته بودم. با توربو سی:
#include <iostream.h>
#include <math.h>
#include <conio.h>
#define X 2.2


void main()
{
float x,y;
char C;
int i=219;
C=i;
for(x=0;x<=4;x+=0.1){
y=sqrt(16-x*x);

gotoxy(X*(15+2*x),(10-2*y));
cout<<C;

gotoxy(X*(15+2*x),(2*y+10));
cout<<C;

gotoxy(-X*(-15+2*x),10-2*y);
cout<<C;

gotoxy(-X*(-15+2*x),10+2*y);
cout<<C;
}
cin>>"";

}





الان توی دِو سی پی پی یه تغییراتی می دم:
#include <iostream.h>
#include <math.h>
#include <windows.h>
#define X 2.2

void gotoxy(int x, int y)
{
static HANDLE h = NULL;
if(!h)
h = GetStdHandle(STD_OUTPUT_HANDLE);
COORD c = { x, y };
SetConsoleCursorPosition(h,c);
}

int main()
{
float x,y;
char C;
int i=219;
C=i;
for(x=0;x<=4;x+=0.1){
y=sqrt(16-x*x);

gotoxy(X*(15+2*x),(10-2*y));
cout<<C;

gotoxy(X*(15+2*x),(2*y+10));
cout<<C;

gotoxy(-X*(-15+2*x),10-2*y);
cout<<C;

gotoxy(-X*(-15+2*x),10+2*y);
cout<<C;
}
cin>>C;
return 0;
}



موفق باشید.