Dreieck
-
also das sollte so aussehen
http://img15.imageshack.us/img15/3184/dreieckrechts.png
Und wenn ich das hier eingebe
for(y=1; y<=N; y++)
{
char line[y+1];for(x=0; x<y; x++)
{
line[x]='*';
}
line[y]=0;
cout << setw(N) << line << endl;dann erhalte ich ein dreieck das rechts ist und noch gefüllt
ich wollte aber wissen ob ich das auch ohne line hinkriege? und wie ich das leer krieg?
-
Das bild sieht aber voll lustig aus

Wie hast du das hinbekommen?
-
Habs bei Paint gemacht XD
konnte es nicht hier in diesem editor erstellen.
-
Taikun schrieb:
for(y=1; y<=N; y++)
{
char line[y+1];for(x=0; x<y; x++)
{
line[x]='*';
}
line[y]=0;
cout << setw(N) << line << endl;hmm...
Was ist das?
Schick mal den ganzen code.
-
#include <iostream>
#include <iomanip>
#include <math.h>using namespace std;
int main()
{
int x;
int y;
int N;cout << "Bitte gib eine Anzahl ein: " << endl;
cin >> N;for(y=1; y<=N; y++)
{
char line[y+1];for(x=0; x<y; x++)
{
line[x]='*';
}
line[y]=0;
cout << setw(N) << line << endl;}
return 0;
}lautet der volle code
-
#include <iostream> using namespace std; int main(int argc, char *argv[]) { int size = 0; cout << "Bitte gib eine Anzahl ein: " << endl; cin >> size; int diagonale = size-1; for(int i=0; i<size-1; ++i) { for(int j=0; j<size-1; ++j) { // bei Diagonaler * setzen ansonsten nicht if(diagonale == j) cout << "*"; else cout << " "; } // letztes Zeichen der Zeile cout << "*" << endl; --diagonale; } cout.fill('*'); cout.width(size); cout << ""; return 0; }und mein essen ist verbrannt!!!
-
boah geil danke
sry um dein verbranntes essen XD
-
kann mir einer noch bei dieser aufgabe helfen?
#include <iostream>
#include <iostream>
using namespace std;
int main()
{
int G;
int A;
int x;
int y;cout << "Bitte geben sie Groesse ein: " << endl;
cin >> G;
cout << "Bitte geben sie Anfangsgroesse ein: " << endl;
cin >> A;for(y=G+A; y<G2; y++)
{
for(x=0; x<y; x++)
{
if(G<18)
{
cout << "";
}
else
{
cout << " ";
}
}
cout << endl;
}
return 0;
}das problem bei dieser aufgabe ist das ich wohl die if abfrage falsch geschrieben hab. Beim linken bild gibt man für die groeße 11 ein und die anfängsgroeße 0. Wenn man aber jetzt statt anfangsgroeße 0 jetzt 5 eingibt dann sollte ein anderes bild entstehen. (siehe unten)
Ich brauch also hilfe bei der If abfrage XD
-
kommt mir irgendwo bekannt vor

http://www.c-plusplus.net/forum/viewtopic-var-t-is-266878.html
-
ich hab heut zuviel langeweile

#include <iostream> #include <iomanip> using namespace std; int main(int argc, char *argv[]) { int size = 0; int begin = 0; cout << "Bitte gib eine Groese ein: " << endl; cin >> size; cout << "Bitte gib eine Anfangsgroesse ein: " << endl; cin >> begin; for(int i=0; i<size; ++i) { std::cout << std::setw(size*2-begin) << std::setfill('*') << "" << std::endl; --begin; if(begin < 0) begin = 0; } return 0; }
-
boah geil danke^^
gut das du soviel langeweile hast^^
-
Taikun schrieb:
gut das du soviel langeweile hast^^
Bequem ja, gut langfristig aber eher nicht.