BlackBoard (http://www.black-board.net/index.php)
- Design, Programmierung & Entwicklung (http://www.black-board.net/board.php?boardid=55)
-- Programmieren (http://www.black-board.net/board.php?boardid=4)
--- C++ "Christbaum" ausgeben (http://www.black-board.net/thread.php?threadid=3900)


Geschrieben von Pille am 03.03.2002 um 19:48:

  "Christbaum" ausgeben

da ich bei C++ in den kinderschulen kaum laufen kann brauche ich eure hilfe!

kann mir jemand den quelltext des folgenden schreiben und posten?

also die aufgabe:
-schreiben sie ein programm, das einen 'christbaum' beliebiger grösse auf dem bildschirm ausgibt. die ausgabe soll so formatiert mittig auf dem bildschirm erfolgen:


*
**
***
****
*****
usw.

edit:
hab ihn von einem freund bekommen können ...


code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:

#include <iostream.h>
#include <conio.h>

int main()
{
clrscr();

char zeichen='*';
int spalten=0;
int k=39;
int l=1;

     cout<<"Wie groß soll der baum sein (max. 25)"<<endl;
     cin>>spalten;

for(int h=0;h<=spalten;h++)
{
for(int i=0;i<=k;i++)
{
cout<<" ";
}

k=k-1;

for(int m=1;m<=l;m++)
{
cout<<zeichen;
}
l=l+2;

cout<<endl;
}

getch();
return 0;

} 




Geschrieben von michisider am 07.12.2009 um 23:07:

 

Für alle die Ihre Schuhe noch an Weihnachten nach drausen stellen.

Marry Chrismas! smile


code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
//---------------------------------------------------------------------------
// TanneBaum COPYRIGHT BY michisider (C)
//---------------------------------------------------------------------------
#include <vcl\condefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h> //cout
#include <windows.h>   //cprint
#include <conio.h>    //farbe
#pragma hdrstop
//---------------------------------------------------------------------------
// Speichern vor der Nutzung
//---------------------------------------------------------------------------
int main(int argc, char **argv)
{
	int Hoehe, Zahl1, c; //Defination
    textcolor (WHITE);
	cprintf ("Soll es Weihnachten? Dann sag mal wie gross :P... ");
    cout << endl;
    cin >> Hoehe;   //beliebige größe!
    c=30;
    for (Zahl1 = 0; Zahl1 < Hoehe; Zahl1 ++) //Schleife innenleben und abstand
    {
        for (int i = 0; i < (c-Zahl1); i++)    //schleife mittig
        {
        	cout << " ";
        }
        if (Zahl1 == 0)
        {
            textcolor(YELLOW);

            cprintf (" **");

        }

        else
        {
            textcolor (14);      //farben
            cprintf ("i");
            textcolor (GREEN);
    		cprintf ("/");
            for (int a =0; a < Zahl1; a ++)
            {
             	textcolor (GREEN);
            	cprintf ("²³");
            }
            textcolor (GREEN);
            cprintf ("\\");
            textcolor (14);
            cprintf ("i");
        }
        cout << endl;
    }

    for (int b = 0; b < (c-Zahl1); b++)    //schleife runtererrand
        {
        	cout << " ";
        }

        cout << "  ";
    for (int b = 0; b < Hoehe; b++)   //schleife stamm
    {
        textcolor (GREEN);
    	cprintf ("--");

    }
    textcolor (BROWN);
	cout << endl;
    cprintf("                               | |");
    cout << endl;
    textcolor (BROWN);
    cprintf ("                               |_|");
    cout << endl;
    cout << endl;
    cout << endl;
    cout<<"               MARRY CHRISMAS AND A HAPPY NEW YEAR!!!";  //endtext


	getchar();  //abbruch auf tastendruck
	return 0;
}
//---------------------------------------------------------------------------
// COPYRIGHT BY michisider
//---------------------------------------------------------------------------



Ich habe für diesen Baum eine Schriftliche Note von "Sehr gut" bekommen.
Sollte einwandfrei gehen Augenzwinkern !


Forensoftware: Burning Board 2.3.6, entwickelt von WoltLab GmbH