[AIDE] gestion d'un tableau avec des fonction
Résolu/Fermé
ribery_7_91
Messages postés
233
Date d'inscription
jeudi 22 novembre 2007
Statut
Membre
Dernière intervention
4 septembre 2010
-
22 déc. 2007 à 20:50
ribery_7_91 Messages postés 233 Date d'inscription jeudi 22 novembre 2007 Statut Membre Dernière intervention 4 septembre 2010 - 23 déc. 2007 à 13:27
ribery_7_91 Messages postés 233 Date d'inscription jeudi 22 novembre 2007 Statut Membre Dernière intervention 4 septembre 2010 - 23 déc. 2007 à 13:27
A voir également:
- [AIDE] gestion d'un tableau avec des fonction
- Tableau croisé dynamique - Guide
- Fonction si et - Guide
- Tableau ascii - Guide
- Tableau word - Guide
- Virginie organise un rallye avec 30 équipes. elle veut créer un code pour désigner chaque équipe. elle a commencé à la main, mais elle voudrait le faire calculer à l'aide d'une formule. proposez une formule comportant une seule fonction et à recopier vers le bas dans la colonne a du fichier à télécharger. quelle formule sera en a9 ? ✓ - Forum Programmation
4 réponses
lami20j
Messages postés
21331
Date d'inscription
jeudi 4 novembre 2004
Statut
Modérateur, Contributeur sécurité
Dernière intervention
30 octobre 2019
3 567
23 déc. 2007 à 00:05
23 déc. 2007 à 00:05
Salut,
à toi d'adapter (j'ai testé sous Linux et ça marche chez moi)
remplace system("clear"); avec clrsrc()
à toi d'adapter (j'ai testé sous Linux et ça marche chez moi)
remplace system("clear"); avec clrsrc()
#include <stdio.h> #include<stdlib.h> #define TAILLE 10 void initialisation (int *tab); void affiche_tableau (int *tab); void modif_case (int *tab); void affiche_case (int *tab); int menu (); int main () { int choix; int *tab; if ((tab = (int *) malloc (TAILLE * sizeof (int))) == NULL) return -1; do{ choix = menu (); switch (choix){ case 1: system("clear"); initialisation (tab); break; case 2: system("clear"); affiche_tableau (tab); break; case 3: system("clear"); modif_case (tab); break; case 4: system("clear"); affiche_case (tab); break; } }while (choix < 5); printf ("%d\n", choix); return 0; } int menu (){ int choix; printf ("\n**********************************************\n"); printf ("* Gestion d'un tableau de 10 entiers *\n"); printf ("**********************************************\n\n"); printf (" MENU \n"); printf ("1 - Initialisation de toutes les cases du tableau\n"); printf ("2 - Affichage de toutes les cases du tableau\n"); printf ("3 - Modification d'une valeur du tableau\n"); printf ("4 - Affichage d'une case \n"); printf ("5 - Quitter\n\n"); printf ("Quel est votre choix?? "); scanf ("%d", &choix); return choix; } void initialisation (int *tab){ int i; for (i = 0; i < TAILLE; i++){ printf (" valeur dans la case numéro %d : ", i + 1); scanf ("%d", &tab[i]); } printf ("Vous avez initialisé le tableau\n"); } void affiche_tableau (int *tab){ int i; for (i = 0; i < TAILLE; i++) printf ("%d ", tab[i]); printf ("\n"); } void modif_case (int *tab){ int i, nb; printf ("Modifier la case numéro : "); scanf ("%d", &i); printf ("Entrez la nouvelle valeur : "); scanf ("%d", &nb); tab[i - 1] = nb; } void affiche_case (int *tab){ int i; printf ("Afficher la case numéro : "); scanf ("%d", &i); printf ("%d\n", tab[i - 1]); }
ribery_7_91
Messages postés
233
Date d'inscription
jeudi 22 novembre 2007
Statut
Membre
Dernière intervention
4 septembre 2010
16
23 déc. 2007 à 13:11
23 déc. 2007 à 13:11
Merci lami20j mais j'ai un dernier petit problème je voudrais faire sans les étoiles qui sont devant les noms de variables alors comment puis je faire???
lami20j
Messages postés
21331
Date d'inscription
jeudi 4 novembre 2004
Statut
Modérateur, Contributeur sécurité
Dernière intervention
30 octobre 2019
3 567
23 déc. 2007 à 13:20
23 déc. 2007 à 13:20
Les varaibles *var se sont des variables pointeurs)
Comme ça?
Comme ça?
#include <stdio.h> #include<stdlib.h> #define TAILLE 10 void initialisation (int tab[]); void affiche_tableau (int tab[]); void modif_case (int tab[]); void affiche_case (int tab[]); int menu (); int main () { int choix; int tab[TAILLE]; do{ choix = menu (); switch (choix){ case 1: system("clear"); initialisation (tab); break; case 2: system("clear"); affiche_tableau (tab); break; case 3: system("clear"); modif_case (tab); break; case 4: system("clear"); affiche_case (tab); break; } }while (choix < 5); printf ("%d\n", choix); return 0; } int menu (){ int choix; printf ("\n**********************************************\n"); printf ("* Gestion d'un tableau de 10 entiers *\n"); printf ("**********************************************\n\n"); printf (" MENU \n"); printf ("1 - Initialisation de toutes les cases du tableau\n"); printf ("2 - Affichage de toutes les cases du tableau\n"); printf ("3 - Modification d'une valeur du tableau\n"); printf ("4 - Affichage d'une case \n"); printf ("5 - Quitter\n\n"); printf ("Quel est votre choix?? "); scanf ("%d", &choix); return choix; } void initialisation (int tab[]){ int i; for (i = 0; i < TAILLE; i++){ printf (" valeur dans la case numéro %d : ", i + 1); scanf ("%d", &tab[i]); } printf ("Vous avez initialisé le tableau\n"); } void affiche_tableau (int tab[]){ int i; for (i = 0; i < TAILLE; i++) printf ("%d ", tab[i]); printf ("\n"); } void modif_case (int tab[]){ int i, nb; printf ("Modifier la case numéro : "); scanf ("%d", &i); printf ("Entrez la nouvelle valeur : "); scanf ("%d", &nb); tab[i - 1] = nb; } void affiche_case (int tab[]){ int i; printf ("Afficher la case numéro : "); scanf ("%d", &i); printf ("%d\n", tab[i - 1]); }
ribery_7_91
Messages postés
233
Date d'inscription
jeudi 22 novembre 2007
Statut
Membre
Dernière intervention
4 septembre 2010
16
23 déc. 2007 à 13:27
23 déc. 2007 à 13:27
Merci problème résolu tu es trop sympa lami20j
Viens sur msn on pourra discuter ça peut étre cool
Viens sur msn on pourra discuter ça peut étre cool