• [^] # Re: Pas vraiment le C

    Posté par (site web personnel, Mastodon) . En réponse au message Graphisme retro en console. Évalué à 4.

    Une version Fortran :

    program main
     implicit none
    integer :: x
     real :: y
     real :: PI = acos(-1.0)
     character :: ESC = achar(27) ! Caractère d'échappement
     integer :: COLS = 40
     ! Efface l'écran
     write(*, "(A)") ESC//"[2J"
     do x = 1, COLS
     y = sin((x-1)*4*PI/COLS) * (COLS-1) / 2.5 + (COLS+1)/2.0
     ! Positionne le caractère "*" aux coordonnées x,y :
     write(*, '(a1, "[", i0, ";", i0, "H*")') ESC, nint(y), x
     end do
     write(*, "(A)", advance="no") ESC//"[0;0H" 
    end program main
     * *
     * * * *
     * * * *
     * * * *
     * * * *
     *
    * * *
     * * * *
     * * * *
     * * * *
     * * * *
     * *