Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

dot

Supermoderator

Beiträge: 9 757

Wohnort: Graz

  • Private Nachricht senden

21

30.08.2006, 22:53

C-/C++-Quelltext

1
;

Anonymous

unregistriert

22

30.08.2006, 23:06

Zitat von »"dot"«

C-/C++-Quelltext

1
;


Jedes Programm brauch eine Main Funktion. ;)

grek40

Alter Hase

Beiträge: 1 491

Wohnort: Dresden

  • Private Nachricht senden

23

30.08.2006, 23:07

Zitat

Zitat

Inwiefern soll das Programm denn schwachsinnig sein?

Autsch, das wirf schlechtes Licht auf.

Das bezog sich nicht auf dein Programm, sondern auf die Aufgabenstellung!


Zitat

Titel: Schwachsinn als kunst


Kunst fordert Kreativität - also nich die Aufgabenstellung hinterfragen sondern loslegen :lol:

dot

Supermoderator

Beiträge: 9 757

Wohnort: Graz

  • Private Nachricht senden

24

30.08.2006, 23:10

Zitat

Jedes Programm brauch eine Main Funktion.


falsch, es handelt sich um ein gültiges C++ programm...

von linken hat keiner was gesagt :P

Sheddex

unregistriert

25

30.08.2006, 23:11

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define SINNLOS1 int
#define SINNLOS2 main
#define SINNLOS3 (void)
#define SINNLOS4 {
#define SINNLOS5 SINNLOS:
#define SINNLOS6 goto SINNLOS;
#define SINNLOS7 return 0;
#define SINNLOS8 }

#define SINNLOS1UND2 SINNLOS1 SINNLOS2
#define SINNLOS3UND4 SINNLOS3 SINNLOS4
#define SINNLOS5UND6 SINNLOS5 SINNLOS6
#define SINNLOS7UND8 SINNLOS7 SINNLOS8

#define SINNLOS1UND2UND3UND4 SINNLOS1UND2 SINNLOS3UND4
#define SINNLOS5UND6UND7UND8 SINNLOS5UND6 SINNLOS7UND8

#define ALLESSINNLOSE SINNLOS1UND2UND3UND4 SINNLOS5UND6UND7UND8 

//Das Programm

ALLESSINNLOSE


OK, halb geklaut ;)

dot

Supermoderator

Beiträge: 9 757

Wohnort: Graz

  • Private Nachricht senden

26

30.08.2006, 23:12

C-/C++-Quelltext

1
2
3
4
5
int main()
{
    main();
    return 0;
}


oder eines ohne stack overflow


C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
__declspec( naked ) void doItBabe()
{
    __asm pop eax
    //play it again, sam!

    doItBabe();
};

int main()
{

    doItBabe();

    return 0;
}



das könnte auch lustig sein

C-/C++-Quelltext

1
2
3
4
5
6
7
int main()
{

    __asm __emit 0x0 __asm __emit 0x1 __asm __emit 0x2 __asm __emit 0x3

    return 0;
}

Anonymous

unregistriert

27

30.08.2006, 23:29

C-/C++-Quelltext

1
2
3
#include <iostream.h> using namespace std; char* a; char *b; 
int main(void){cout<<"a eingeben: "; cin>>a; cout << endl << "b
 eingeben:"; cin>>b; cout<<endl<<"c"; cin.get(); return 0;}


Das haut doch rein. =)

Sheddex

unregistriert

28

30.08.2006, 23:49

Was ist daran so schlimm? So code ich schon die ganze Zeit... :lol: ;)

David Scherfgen

Administrator

Beiträge: 10 382

Wohnort: Hildesheim

Beruf: Wissenschaftlicher Mitarbeiter

  • Private Nachricht senden

29

30.08.2006, 23:55

So, das ist ziemlich schwachsinnig - funktioniert aber.

Exceptions statt Rückgabewerte!
Casting-Chaos und Float-Bitmanipulation! :D

C-/C++-Quelltext

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <cmath>

class KurzeZahl
{
public:
    void setzeWert(short x)
    {
        while(++wert != x);
    }

    void gibWert() const
    {
        throw wert;
    }

    void gibVorzeichen() const
    {
        if(!wert) throw static_cast<char>(wert);
        throw static_cast<char>(wert / sqrtf(static_cast<float>(wert * wert)));
    }

    void gibBetrag() const
    {
        try { gibVorzeichen(); }
        catch(char vz)
        {
            if(!vz) throw static_cast<short>(vz);
            float invVz = 1.0f / vz;
            throw static_cast<short>(invVz * wert);
        }
    }

    void operator + (const KurzeZahl& rhs) const
    {
        KurzeZahl ergebnis = *this;
        try { rhs.gibWert(); }
        catch(short w)
        {
            try { rhs.gibVorzeichen(); }
            catch(char vz)
            {
                while(vz ? (vz > 0 ? w-- : w++) : vz)
                {
                    try { ergebnis.gibWert(); }
                    catch(short t)
                    {
                        ergebnis.setzeWert(vz > 0 ? ++t : --t);
                    }
                }
            }
        }

        throw ergebnis;
    }

    void operator - () const
    {
        KurzeZahl ergebnis = *this;
        float negiert = static_cast<float>(ergebnis.wert);
        reinterpret_cast<char*>(&negiert)[3] ^= 1 << 7;
        ergebnis.setzeWert(static_cast<short>(negiert));
        throw ergebnis;
    }

    void operator - (const KurzeZahl& rhs) const
    {
        try { -rhs; }
        catch(KurzeZahl negiert)
        {
            *this + negiert;
        }
    }

private:
    short wert;
};

int main()
{
    KurzeZahl a, b;

    a.setzeWert(13);
    b.setzeWert(29);

    try { a + b; }
    catch(KurzeZahl c)
    {
        try { c.gibWert(); }
        catch(short cw)
        {
            printf("13 + 29 = %d\n", cw);
        }
    }

    try { a - b; }
    catch(KurzeZahl c)
    {
        try { c.gibWert(); }
        catch(short cw)
        {
            printf("13 - 29 = %d\n", cw);
        }
    }

    return 0;
}

matthias

Alter Hase

Beiträge: 449

Wohnort: wipperfürth

  • Private Nachricht senden

30

31.08.2006, 00:23

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;


public class Katze {

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(true)
        {
            System.out.print("Bitte geben sie eine Katze ein: ");
            String eingabe = scan.next();
            try
            {
                Katze katze = (Katze) (Object) eingabe;
            } catch(Exception e)
            {
                System.out.println("Error, Sie haben keine Katze eingegeben");
            }
            
        }
    }
}

so ists fairer, man muss es ja wenigstens versuchen ;)
"In those days spirits were brave, the stakes were high, men were REAL men, women were REAL women, and small furry creatures from Alpha Centauri were REAL small furry creatures from Aplha Centauri."

Werbeanzeige