Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 10:50

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

Advertisement



Problem mit Array und for Schleife

Discussion on Problem mit Array und for Schleife within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Nov 2012
Posts: 7
Received Thanks: 0
Problem mit Array und for Schleife

Hallo, das folgende programm sollte eigentlich ein 11x11 feld aus zufälligen zahlen ausgeben, macht es allerdings nicht .
Code:
#include <iostream>
using namespace std;
int irand( int min, int max)
{
    double r = max - min + 1;
    return min + (int)(r * rand()/(RAND_MAX+1.0));
}
int main(){

int dungeon[10][10];
for(int i = 0;i=!10;i++){
for(int j = 0;j=!10;j++){
dungeon[i][j] = irand(1,2);
cout << dungeon[i][j];
}
cout << endl;
}
system("pause");
}
problem gelöst, fehler in der for schleife:
Code:
#include <iostream>
using namespace std;
int irand( int min, int max)
{
    double r = max - min + 1;
    return min + (int)(r * rand()/(RAND_MAX+1.0));
}
int main(){

int dungeon[10][10];
for(int y = 0;y<10;y++){
for(int x = 0;x<10;x++){
dungeon[x][y] = irand(1,2);
cout << dungeon[x][y];
if(x==10){ y=0;}
}
cout << endl;
}
system("pause");
}
crApple is offline  
Reply

Tags
array, dungeon


Similar Threads Similar Threads
Array Definieren in For-Schleife
02/14/2011 - AutoIt - 2 Replies
Hi, Warum ist es nicht möglich, dieses Array zu definieren: Dim $DIni For $u=0 to 19 step 1 Global $DIni=IniRead(@WindowsDir&"\hsdata.ini&qu ot;,"sDesktop",$u,"") Next Sollte doch eigentlich klappen!?
[Schleife]Problem
10/24/2010 - AutoIt - 19 Replies
Hi Leute, ich amch gerade nen Hack für Metin2. So ich hab folgendes Problem: Wenn ich den hack starten will, drücke ich auf $button1 dann schreibt er in den pointer mit
Array-Problem
05/13/2010 - AutoIt - 0 Replies
Also ich habe die System-Zeit und das System-Datum in einen Array geladen: #include <Date.au3> Global $dat, $tim $dat = _NowCalcDate() If @error Then Return $tim = _NowTime(5)
Autoit - If Schleife - Problem
05/27/2009 - AutoIt - 3 Replies
Huhu, hab nen kleines Problem mit ner If-Schleife: $pixel_mob = PixelGetColor (549, 68) $farbe_mob = Hex($pixel_mob, 6) if $farbe_mob = 'CE0000' Then ToolTip('Attacking...',0,0)
Autoit - Problem mit If-Schleife
05/27/2009 - General Coding - 1 Replies
Huhu, erstmal ne kleine Frage...hab gerade zu diesem Thema nen Beitrag geschrieben, flupps, 5 Minuten später war er gelöscht - keine PN, nix.. Naja...mal schaun ^^ Problem ist folgendes: Hab diese if schleife in meiner while schleife:



All times are GMT +1. The time now is 10:51.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.