15/01/17 12:24
Poggi Marco
Le variabili e ed f, siccome ricevono il risultato di calcoli con le funzioni sin e cos, devono essere dichiarate come real.
Inoltre sin ( a ) e cos ( a ) calcolano in seno e coseno di un angolo espresso in radianti.
Ho rivisto il programma:
Inoltre sin ( a ) e cos ( a ) calcolano in seno e coseno di un angolo espresso in radianti.
Ho rivisto il programma:
program LineaColorata; uses crt,graph; const L=50; var p1,p2,n2,colore,colore2:smallint; n,s,f,e, convertiInRadianti:real; a:integer; Gd,Gm:smallint; begin detectgraph(Gd,Gm); initgraph(Gd,Gm,'c:\dev-pascal'); p1:=80; p2:=50; n:=0; s:=0; f:=0; e:=0; convertiInRadianti:=PI/180; (* fattore di conversione da gradi in radianti*) repeat begin for a:=0 to 40 do begin colore:=15; (*trunc(n); commento le funzioni trunc trunc(s); *) n:= COS(a*convertiInRadianti)*(L); s:= SIN(a*convertiInRadianti)*(L); setcolor(colore); line(p1,p2,round(n),round(s)); ClearDevice; end; for a:=41 to 80 do begin colore:=14; (* trunc(n); trunc(s); *) n:= COS(a*convertiInRadianti)*(L); s:= SIN(a*convertiInRadianti)*(L); setcolor(colore); line(p1,p2,round(n),round(s)); ClearDevice; end; for a:=81 to 120 do begin colore:=6; (* trunc(n); trunc(s); *) n:= COS(a*convertiInRadianti)*(L); s:= SIN(a*convertiInRadianti)*(L); setcolor(colore); line(p1,p2,round(n),round(s)); ClearDevice; end; for a:=121 to 160 do begin colore:=12; (* trunc(n); trunc(s); *) n:= COS(a*convertiInRadianti)*(L); s:= SIN(a*convertiInRadianti)*(L); setcolor(colore); line(p1,p2,round(n),round(s)); ClearDevice; end; for a:=161 to 180 do begin colore:=5; (* trunc(n); trunc(s); *) n:= COS(a*convertiInRadianti)*(L); s:= SIN(a*convertiInRadianti)*(L); setcolor(colore); line(p1,p2,round(n),round(s)); ClearDevice; end; for a:=181 to 200 do begin colore2:=5; (*trunc(f); trunc(e); *) f:= COS(a*convertiInRadianti)*(L); e:= SIN(a*convertiInRadianti)*(L); setcolor(colore2); line(p1,p2,round(f),round(e)); ClearDevice; end; for a:=201 to 240 do begin colore2:=11; (*trunc(f); trunc(e);*) f:= COS(a*convertiInRadianti)*(L); e:= SIN(a*convertiInRadianti)*(L); setcolor(colore2); line(p1,p2,round(f),round(e)); ClearDevice; end; for a:=241 to 280 do begin colore2:=1; {trunc(f); trunc(e);} f:= COS(a*convertiInRadianti)*(L); e:= SIN(a*convertiInRadianti)*(L); setcolor(colore2); line(p1,p2,round(f),round(e)); ClearDevice; end; for a:=281 to 320 do begin colore2:=2; (* trunc(f); trunc(e);*) f:= COS(a*convertiInRadianti)*(L); e:= SIN(a*convertiInRadianti)*(L); setcolor(colore2); line(p1,p2,round(f),round(e)); ClearDevice; end; for a:=321 to 360 do begin colore2:=10; (* trunc(f); trunc(e);*) f:= COS(a*convertiInRadianti)*(L); e:= SIN(a*convertiInRadianti)*(L); setcolor(colore2); line(p1,p2,round(f),round(e)); ClearDevice; end; end; until(keypressed); closegraph; end.
aaa