cs_darkwhite
Messages postés133Date d'inscriptionvendredi 17 novembre 2000StatutMembreDernière intervention29 avril 2008
-
20 juin 2006 à 23:15
Jomba
Messages postés58Date d'inscriptionmercredi 2 novembre 2005StatutMembreDernière intervention22 juillet 2010
-
26 juin 2006 à 15:27
Salut a tous, je suis debutant en C
Je voudrai remplir un tableau a deux dimensions de la façon suivant
12345
22345
33345
44445
55555
...etc
Voila la reponsse doit etre simple ? mais je suis debutant donc merci d'avance!
gbourgeois0019
Messages postés152Date d'inscriptionlundi 3 avril 2006StatutMembreDernière intervention 2 juin 20081 20 juin 2006 à 23:26
int Tab[5][5];
for ( int i = 0 ; i < 5 ; i++ )
{
for ( int j = 0 ; j < 5; j++ )
{
if ( j <= i )
Tab[i][j] = i;
else
Tab[i][j] = j;
}
}
J'ai pas testé mais je pense que ca dervais marcher
________________________________________________________________________
Hardware is what we play with until it breaks, Software is what we play with until it works !
gbourgeois0019
Messages postés152Date d'inscriptionlundi 3 avril 2006StatutMembreDernière intervention 2 juin 20081 20 juin 2006 à 23:27
int Tab[5][5];
for ( int i = 1 ; i <= 5 ; i++ )
{
for ( int j = 1 ; j <= 5; j++ )
{
if ( j <= i )
Tab[i][j] = i;
else
Tab[i][j] = j;
}
}
Petite erreur dans mes boucles
________________________________________________________________________
Hardware is what we play with until it breaks, Software is what we play with until it works !
vecchio56
Messages postés6535Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention22 août 201014 20 juin 2006 à 23:47
Non ton premier message est mieux (on commence à zéro) et on arrête à 4
Quand a savoir si ca donne le bon résultat je sais pas, ca me donne mal à la tête
_____________________________________
Vous n’avez pas trouvé la réponse que vous recherchez ?
gbourgeois0019
Messages postés152Date d'inscriptionlundi 3 avril 2006StatutMembreDernière intervention 2 juin 20081 20 juin 2006 à 23:49
J'ai commencé a 1 pour finir a 5 puis qu'il voulait 12345 et non 01234 ... j'aurait pu de 0 a 4 en mettant i-1 et j-1 ce qui aurait donné le même résultat
________________________________________________________________________
Hardware is what we play with until it breaks, Software is what we play with until it works !
gbourgeois0019
Messages postés152Date d'inscriptionlundi 3 avril 2006StatutMembreDernière intervention 2 juin 20081 20 juin 2006 à 23:50
Pour ce qui est du principe t'a qu'a t'imaginer étant un débugger et suivre pas a pas tu va comprendre c,est pas sorcier
________________________________________________________________________
Hardware is what we play with until it breaks, Software is what we play with until it works !