Autor Beitrag
felix96
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34


VS 2010 Express
BeitragVerfasst: Mi 21.07.10 11:26 
Hallo,
ich wollte als mein erstes C# Programm ein Lotto-Programm erstellen, und war von der Option "Browseranwendung" so begeistert, dass ich diese genommen hab.
Aber bei dem Quellcode:
ausblenden volle Höhe 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:
            Random zufall = new Random(DateTime.Now.Millisecond);
            int z1, z2, z3, z4, z5, z6;

            z1 = zufall.Next(150);

            do
            {
                z2=zufall.Next(1,50);
            }
            while (z1!=z2);

            do
            {
                z3 = zufall.Next(150);
            }
            while (z3 != z2 && z3!=z1);

            do
            {
                z4 = zufall.Next(150);
            }
            while (z4 != z2 && z4 != z1 && z4!=z3);

            do
            {
                z5 = zufall.Next(150);
            }
            while (z5 != z2 && z5 != z1 && z5 != z3 && z5!=z4);

            do
            {
                z6 = zufall.Next(150);
            }
            while (z6 != z2 && z6 != z1 && z6 != z3 && z6 != z4 && z6!=z5);


sind alle Zahlen immer gleich.
Wenn z1 5 ist, sind alle Zahlen 5.
Aber in meinem Buch steht (soweit ich das richtig verstanden habe) das == der Gleichheitsoperator ist, und != der ungleich.
Wist ihr die Lösung?

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 21.07.10 11:28 
Übersetzt heißt doch z.B. Deine erste Schleife: "mache ... so lange wie z1 ungleich z2 ist". Oder andersrum: "Höre erst auf, wenn beide gleich sind".

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".

Für diesen Beitrag haben gedankt: felix96
felix96 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34


VS 2010 Express
BeitragVerfasst: Mi 21.07.10 11:33 
Danke :-)