- Code: Select all
#include <iostream>
#include <math.h>
using namespace std;
void dessine(int nb,int rmin,int rmax)
{
int i,j,s;
float L,t,pi,angler,x,y;
bool finRadius;
pi = 4.0*atan(1.0);
angler = 2.0*pi/(int)nb;
for(i=0;i<=rmax*2;i++)
{
for(j=0;j<=rmax*2;j++)
{
x = (float)j-(float)rmax;
y = (float)i-(float)rmax;
L = sqrt(x*x+y*y);
t = acos(x/L);
if (y<0) {t=2.0*pi-t;}
s = 0;
finRadius = false;
while ((s<nb+1) and (finRadius=false))
{
if ((rmin<=L) and (L<=rmax) and ((fabs(t-(float)s*angler)<angler/L) or (fabs(rmin-L)<1)))
{
cout << "00";
finRadius = true;
}
else
{s = s+1;}
}
if (s == nb+1) {cout << "..";}
}
cout << endl;
}
}
int main(void)
{
int nb,rmin,rmax;
nb = 10;
rmin = 5;
rmax = 14;
dessine(nb,rmin,rmax);
return 0;
}
que j'ai deduis du pdf en attachement a traduire.... ou est mon erreur ?