مشاهدة النسخة كاملة : switch case algorithme
Salem Alaikoum
SVP j'ai besoin de savoir comment ecrir un algorithme en utilisant la structure switch case
Merci
switch(المتغير الذي نريد ان نعمل عليه test)
case و نكتب الحالة الاولى التي ممكن يكون عليها المتغير
ثم نكتب ما هي الاجراءات التي يجب اتخاذها عند اخذ المتغير هاته القيمة
كل حالة نعملهها كيز التي تخصها
اليك مثال
2 ce code est une fonction(langage C) qui verifie un choix d'entier entre 1 et
void print_cas(int choix)
{
switch (choix)
{
case 1 : printf("tu a choisir le premier choix "); break;
case 2 : printf("tu a choisir le deuxieme choix"); break;
default : printf("tu a choisi un numero faut\n");
}
}
merci pour votre réponse ; je cherche le switch case en algo pas en code c
merci pour votre réponse ; je cherche le switch case en algo pas en code c
en algorithmique switch s'ecrit comme des if successive cad chaque choix se represente par un if
{si( choix = 1) alors{ afficher votre choix est le num 1
sinon
{si (choix =2) alors {afficher votre choix est num 2
sinon
afficher erreur
}
sinon
~عابر سبيل~
2016-02-19, 00:08
السلام عليكم ~
selon choix
case 1 : instruction 1
case2 : instr 2
.
.
case n : instr n.
autre : cas d'erreur ou...
vBulletin® v3.8.10 Release Candidate 2, Copyright ©2000-2024, TranZ by Almuhajir