Instruction SWAP sur Qbasic
Fermé
rsca0123
Messages postés
5
Date d'inscription
vendredi 13 mars 2009
Statut
Membre
Dernière intervention
23 mai 2011
-
23 mai 2011 à 19:01
qbasic45 Messages postés 55 Date d'inscription vendredi 14 décembre 2012 Statut Membre Dernière intervention 15 juin 2019 - 18 déc. 2012 à 00:45
qbasic45 Messages postés 55 Date d'inscription vendredi 14 décembre 2012 Statut Membre Dernière intervention 15 juin 2019 - 18 déc. 2012 à 00:45
A voir également:
- Instruction SWAP sur Qbasic
- Swap windows - Guide
- Qbasic - Télécharger - Édition & Programmation
- Swap magic ps2 download ✓ - Forum Image ISO
- Qbasic windows 10 - Forum Windows 10
- Exercices corrigés de qbasic pdf - Forum Programmation
2 réponses
Bonsoir,
en QBasic, l'instruction swap permet d'échanger deux variables (pas les inverser), sans passer par une variable temporaire
si a=0 et b=1, après swap(a,b), a=1 et b=0
donc swap(a,b) est équivalent à
temp=a : a=b : b=temp
bonne suite.
en QBasic, l'instruction swap permet d'échanger deux variables (pas les inverser), sans passer par une variable temporaire
si a=0 et b=1, après swap(a,b), a=1 et b=0
donc swap(a,b) est équivalent à
temp=a : a=b : b=temp
bonne suite.
qbasic45
Messages postés
55
Date d'inscription
vendredi 14 décembre 2012
Statut
Membre
Dernière intervention
15 juin 2019
3
18 déc. 2012 à 00:45
18 déc. 2012 à 00:45
bonjour
dim c$(10)
c$(1)="E"
c$(2)="H"
c$(3)="D"
c$(4)="A"
c$(5)="J"
c$(6)="C"
c$(7)="F"
c$(8)="A"
c$(9)="G"
c$(10)="B"
FOR i = 1 TO 10 - 1
FOR j = i + 1 TO 10
IF c$(j) < c$(i) THEN SWAP c$(i), c$(j)
NEXT j
NEXT i
for a=1 to 10
print c$(a);" ";
next a
donee = A B C D E F G H I J
rem
FOR i = 1 TO 10 - 1
FOR j = i + 1 TO 10
IF c$(j) > c$(i) THEN SWAP c$(i), c$(j)
NEXT j
NEXT i
for a=1 to 10
print c$(a);" ";
next a
donee = J I H G F E D C B A
dim c$(10)
c$(1)="E"
c$(2)="H"
c$(3)="D"
c$(4)="A"
c$(5)="J"
c$(6)="C"
c$(7)="F"
c$(8)="A"
c$(9)="G"
c$(10)="B"
FOR i = 1 TO 10 - 1
FOR j = i + 1 TO 10
IF c$(j) < c$(i) THEN SWAP c$(i), c$(j)
NEXT j
NEXT i
for a=1 to 10
print c$(a);" ";
next a
donee = A B C D E F G H I J
rem
FOR i = 1 TO 10 - 1
FOR j = i + 1 TO 10
IF c$(j) > c$(i) THEN SWAP c$(i), c$(j)
NEXT j
NEXT i
for a=1 to 10
print c$(a);" ";
next a
donee = J I H G F E D C B A