Grafische Ausgabe C++ am PC

Gast #924835
Lesenswert?

Hallo Leute ich hab da mal ein Poblem.
Ich möchte eine Sinus Kurve von 0 bis 2pi in Form von Sternchen 
ausgeben.

Bis jetzt sieht mein Programm so aus:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int b=10;
    int h=10;

    float array[100];
    float arrayy[100];
    int i;
    float x1= (3.1416*2)/b;
    for (i=0; i<b; i++)
    {
        array[i]=x1*(i+1);
    }
    for(i=0; i<b; i++)
             {
           printf("(Index %d) Punktzahl Aufgabe %d: %f\n\n", i, i+1, 
array[i]);
             }
  for (i=0; i<b; i++)

        {
        arrayy[i]=sin(array[i])*h;
        }
    for(i=0; i<b; i++)
    {
           printf("(Index %d) Punktzahl Aufgabe %d: %f\n\n", i, i+1, 
arrayy[i]);
    }


     int brett[100][100] = { 0 };

brett[(int)array[1]][(int)arrayy[1]] = 1;
brett[(int)array[2]][(int)arrayy[2]] = 1;
brett[(int)array[3]][(int)arrayy[3]] = 1;
brett[(int)array[4]][(int)arrayy[4]] = 1;
brett[(int)array[5]][(int)arrayy[5]] = 1;
brett[(int)array[6]][(int)arrayy[6]] = 1;
brett[(int)array[7]][(int)arrayy[7]] = 1;
brett[(int)array[8]][(int)arrayy[8]] = 1;
brett[(int)array[9]][(int)arrayy[9]] = 1;
brett[(int)array[10]][(int)arrayy[10]] = 1;


int  j;

// Schleife fuer Zeilen, Y-Achse
for(i=0; i<10; i++) {
  // Schleife fuer Spalten, X-Achse
  for(j=0; j<10; j++) {
    printf("%d ", brett[j][i]);
  }
  printf("\n");
}




system("pause");
return 0;
}


__________________________


am Ende sollte eigentlich sowas in der Art ausgegeben werden:




    xx
  x    x
 x      x      x
         x    x
           xx


Danke schonmal für eure Hilfe und Anregungen.
Gruß
#925031
Lesenswert?

damit kanns du unter windows den cursor setzen
http://web56.hermes.server-pool.de/pages/ic.c-plusplus.de/

dann findes du heraus wie viele punkte du haben willst,
dann den wert an den punkte stellen sin(i*(2*pi)/npunkte)
skalierst den wert auf die anzahl der y stellen und rundest

fürs rechnen dürfte es einfach sein wenn du den sinus in den postiven 
bereich veschiebst

denke dran das die zeichen höher sind als breiter

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren