If dans un switch langage C
Résolu/Fermé
CoDForlan
Messages postés
33
Date d'inscription
mercredi 17 juin 2020
Statut
Membre
Dernière intervention
16 février 2022
-
16 janv. 2021 à 12:59
CoDForlan Messages postés 33 Date d'inscription mercredi 17 juin 2020 Statut Membre Dernière intervention 16 février 2022 - 16 janv. 2021 à 18:56
CoDForlan Messages postés 33 Date d'inscription mercredi 17 juin 2020 Statut Membre Dernière intervention 16 février 2022 - 16 janv. 2021 à 18:56
A voir également:
- If dans un switch langage C
- D langage c ✓ - Forum C
- If exist ✓ - Forum Autoit / batch
- Télécharger switch - Télécharger - Conversion & Extraction
- Et en langage c - Astuces et Solutions
- Vba if not ✓ - Forum Excel
2 réponses
yg_be
Messages postés
21303
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
18 mars 2023
1 326
16 janv. 2021 à 13:18
16 janv. 2021 à 13:18
bonjour,
pourquoi utilises-tu
pourquoi utilises-tu
--xdans le if?
CoDForlan
Messages postés
33
Date d'inscription
mercredi 17 juin 2020
Statut
Membre
Dernière intervention
16 février 2022
16 janv. 2021 à 17:54
16 janv. 2021 à 17:54
ok c'est bon j'ai réussi merci pour ton aide et j'ai aussi compris les différence entre les versions préfixe et suffixe.
Je ne comprend par contre tjs pas la dif entre ++x et x+1.
Merci ;)
Je ne comprend par contre tjs pas la dif entre ++x et x+1.
Merci ;)
yg_be
Messages postés
21303
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
18 mars 2023
1 326
16 janv. 2021 à 17:56
16 janv. 2021 à 17:56
qu'as-tu programmé?
CoDForlan
Messages postés
33
Date d'inscription
mercredi 17 juin 2020
Statut
Membre
Dernière intervention
16 février 2022
16 janv. 2021 à 17:57
16 janv. 2021 à 17:57
J'ai fais ça à la place et ça fonctionne
for (x=0;x<nbLines;++x){
for (y=0;y<nbCollumns;++y){
if (MAP[x][y]=='X'){
switch(orientation){
case 8:
if(MAP[x-1][y]!='#'){
MAP[x][y]=0;
MAP[--x][y]='X';
}
MAP[x][y]='X';
break;
case 2:
if(MAP[x+1][y]!='#'){
MAP[x][y]=0;
MAP[++x][y]='X';
}
MAP[x][y]='X';
break;
case 4:
if(MAP[x][y-1]!='#'){
MAP[x][y]=0;
MAP[x][--y]='X';
}
MAP[x][y]='X';
break;
case 6:
if(MAP[x][y+1]!='#'){
MAP[x][y]=0;
MAP[x][++y]='X';
}
MAP[x][y]='X';
break;
default:
MAP[x][y]='X';
break;
}
}
}
}
x=0,y=0;
yg_be
Messages postés
21303
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
18 mars 2023
1 326
16 janv. 2021 à 18:21
16 janv. 2021 à 18:21
et tu as compris la différence entre --x, x-- et x-1?
CoDForlan
Messages postés
33
Date d'inscription
mercredi 17 juin 2020
Statut
Membre
Dernière intervention
16 février 2022
>
yg_be
Messages postés
21303
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
18 mars 2023
16 janv. 2021 à 18:23
16 janv. 2021 à 18:23
oui j'ai compris entre --x et x-- mais pas x-1 entre --x
yg_be
Messages postés
21303
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
18 mars 2023
1 326
>
CoDForlan
Messages postés
33
Date d'inscription
mercredi 17 juin 2020
Statut
Membre
Dernière intervention
16 février 2022
16 janv. 2021 à 18:54
16 janv. 2021 à 18:54
x-1ne modifie pas x
16 janv. 2021 à 13:21
16 janv. 2021 à 13:23
16 janv. 2021 à 14:37
16 janv. 2021 à 15:05
16 janv. 2021 à 15:07