Ich versuche ein Programm zu erstellen, das ein Histogramm ist. Sie haben Index: 0,1,2,3,4,5,6,7,8,9 und Werte: Sie fügen sie ein. Für jeden Wert muss ein * angezeigt werden. Zum Beispiel Wert 3 -> *** // Wert 5 -> ***** usw. Ich bekomme alles außer dem * erledigt. Kann mir jemand eine Idee oder ein Beispiel geben, wie es geht? DankHistogramm in C++ mit Arrays
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
// variabili per instogramma
int a=8;
int c=12;
int z=0;
// variabili per vettore
int v;
int numeri[10];
int i=0;
do{
cout<<"Inserisci i numeri:";
cin>> v;
numeri[i]=v;
i+=1;
} while(i<10);
cout<<"\n";
// Mostra Index - Elementi - Instogramma
cout << setw(n) << "Index";
cout << setw(a) << "Valori" << " ";
cout << setw(c) << "Instogramma\n";
for(int z=0;z<10;z++)
{
cout << setw(n) << z;
cout << setw(a) << numeri[z] <<"\n";
}
system("PAUSE");
return EXIT_SUCCESS;
}
Meinst du "Histogramm"? Und bitte den Code einrücken. –
Ja, ich meine Histogramm. – folgore95
Für 1 Druck 1 Stern, für 2 Druck 2 Sterne, für 3 Druck 3 Sterne etc. Wo ist das Problem? –