Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 15:30

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C++]Schleifen,Statements,Menü?

Discussion on [C++]Schleifen,Statements,Menü? within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
BloodlyKnife's Avatar
 
elite*gold: 0
Join Date: Mar 2010
Posts: 188
Received Thanks: 80
Exclamation [C++]Schleifen,Statements,Menü?

Hi ich hab in etwa das gleiche Problem wie VersionX im Main Bereich
Ich bin auch anfänger kann aber schon einiges :P xD

Hier mal ein Code(damit ihr es euch vorstellen könnt):
Code:
#include <iostream>
#include <string>

using namespace std;

main(){

cout << "Wählen sie eine Funktion!" << endl;
cout << "100% mit For-Schleife                    <1>" << endl;
cout << "100% mit While-Schleife                 <2>" << endl;
///usw......

int x1;
cin >> x1;

switch(x1){
case 1:
    for(int i = 0; i == 100; i++){
    cout << i << " %" << endl;
    } 
    getchar();
    break;
case 2:
 int x2 = 0;
while(x2 == 100){
cout << x2 << " %" << endl;
}
getchar();
break;
}
}
So.
Das Konsolen Fenster das sich öffnet ignoriert if statemants und Schleifen.
Das Programm beendet sich einfach mit "Bitte drücken sie eine Beliebige Tase....".
Was kann ich da machen?

Und wie komme ich nach den Herunter zählen der 100% wieder in das Menü wo man auswählen kann was er machen soll?(100% For schleife, 100% while..,)

Gibt für jede Hilfreiche Antwort ein Thanks
Hab auf C++ Deverloper
MFG: BloodlyKnife
BloodlyKnife is offline  
Thanks
1 User
Old 06/10/2010, 13:52   #2
 
elite*gold: 0
Join Date: Nov 2007
Posts: 62
Received Thanks: 17
Kann C++ nicht so gut aber so muss es wohl gehen.
Pass nur auf dass du keine Buchstaben eingibst

Code:
#include <iostream>
#include <string>

void main()
{
	int iSelection, a, b;

menu:
	a = 0;
	b = 0;

	std::cout << "Wählen sie eine Funktion!"   << std::endl;
	std::cout << "100% mit For-Schleife   <1>" << std::endl;
	std::cout << "100% mit While-Schleife <2>" << std::endl;
	std::cin >> iSelection;

	switch (iSelection)
	{
	case 1:
		for (a; a <= 100; a++) // loops 100 times till 100%.
		{
			std::cout << a << "%" << std::endl;
		}
		break;
	case 2:
		while (b <= 100) // loops again 100 times till 100%.
		{
			std::cout << b << "%" << std::endl;
			b++;
		}
		break;
	default:
		std::cout << "Diese Option wurde nicht gefunden!" << std::endl;
		break;
	}

	std::system("PAUSE");
	std::system("CLS");

	goto menu;
}
Demon-777 is offline  
Thanks
1 User
Old 06/10/2010, 13:55   #3
 
elite*gold: 0
Join Date: May 2010
Posts: 793
Received Thanks: 268
Quote:
for(int i = 0; i == 100; i++){
cout << i << " %" << endl;
}
naja du initialisiertst i mit null, und dnn sagtst du "solange i 100 ist" klar, dass der fall nie eintritt

eigentlich willst du ja "solage i kleiner oder gleich 100 ist, richtig währe also "i <= 100"
nkkk is offline  
Thanks
1 User
Old 06/10/2010, 13:55   #4
 
Greysky's Avatar
 
elite*gold: 10
Join Date: Apr 2010
Posts: 333
Received Thanks: 42
hey nice
aber was bringt das^^
krigst trotzdem thx
Greysky is offline  
Old 06/10/2010, 13:56   #5
 
elite*gold: 0
Join Date: Apr 2006
Posts: 6,597
Received Thanks: 1,830
Ich würd mir nochmal genau anschauen wie schleifen funktionieren

die beiden schleifen sollten gehen:

Code:
    for(int i = 0;[B] i < 101[/B]; i++){
    cout << i << " %" << endl;
    }
&

Code:
while([B]x2 < 101[/B]){
cout << x2 << " %" << endl;
[B]x2++;[/B]
}
Medix is offline  
Thanks
1 User
Old 06/10/2010, 14:16   #6
 
P-a-i-n's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 1,258
Received Thanks: 396
das schleifen bis 100 zählen gibt es eine einfache eingabe
1 mal so

Code:
   for(int i = 0; i <= 100; i++
{
    cout << i << " %" << endl;
    }
Code:
while(x2 <= 100)
{
cout << x2 << " %" << endl;
x2++;
}

nur ein <= bedeuted kleiner oder gleich ;D drauß ergibt sich dann die 100
P-a-i-n is offline  
Thanks
1 User
Old 06/11/2010, 20:26   #7
 
elite*gold: 0
Join Date: May 2008
Posts: 489
Received Thanks: 210
Quote:
Originally Posted by Demon-777 View Post
Code:
goto menu;
Ewwwwww.
schlurmann is offline  
Old 06/11/2010, 20:48   #8
 
elite*gold: 100
Join Date: Oct 2007
Posts: 738
Received Thanks: 485
Quote:
Originally Posted by schlurmann View Post
Ewwwwww.
Genau das gleiche hab ich auch gedacht....
ddl is offline  
Reply

Tags
c++, programmieren, schleifen


Similar Threads Similar Threads
Probleme mit den Schleifen x.x
07/23/2010 - AutoIt - 18 Replies
Ja, hallo. :D Mein Problem ist das ich gerne einen Bot bauen würde der einnen Tastendruck ausführt wenn sich ein bestimmer Pixel auf dem Bildschirm verändert. Nur ist das Problem das AutoIt zu lahm ist da der Pixel sich schnell beweget und somit auch seine Farbe ändert und der Bot dann es nichtmehr schafft zuzuschlagen. :P Was ich nun versucht hab ist das man vll. sozusagen eine Tolleranz einbaut wie z.b. bei dem Pixelsearch Befehl nur ich hab ka. wie ich das anstellen soll. Ich...
Kleine Frage zu Schleifen
03/07/2010 - GW Bots - 1 Replies
Ich hab eine kleine Frage: #include (alles notwendige) Do keysend("1") slp(Random(5100,5300)) keysend("2") slp(random(8100,8300)) $color2 = PixelGetColor( 520, 240, $hWnd); muss 7c6d73 sein
Sichere Datenbankzugriffe durch Prepared Statements
03/07/2010 - Tutorials - 4 Replies
Um es gleich zu Anfang zu nennen: Ich werde als Beispiel-Programmier-Sprache PHP wählen, da es mit Abstand am häufigsten dort angewendet werden sollte. Grundsätzlich ist diese Technik auch auf andere Sprachen anwendbar. 1. Etwas Theorie 2. Praktisches 3. Schlusswort Vorwort: PHP hatte lange Zeit keine standardisierte Schnittstelle für Datenbanken, um auf verschiedene Datenbanksysteme zuzugreifen, musste der PHP-Entwickler sich viele verschiedene Funktionen merken. Der...
hackers out there! u can post ur statements here ^^
05/13/2009 - Grand Chase - 32 Replies
juz read the rules over and over again (5x actually) im hopin that this thread will somehow enlightened those MISUSERS on how to use their hacks or someone else's properly. and i guess that this post will not break any of this forum's rules so.. here we go! Why or what is/are the reason/s why you are using hacks in the game? ;) ME= use this hacks coz i want to catch up to my friends playin for a whole weekend w/c are lvl 50+. ( i do have a job ) i guess this hacks really makes me...



All times are GMT +1. The time now is 15:31.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.