السلام عليكم ورحمة الله وبركاته
بما أنه لم يتم ذكر لغة البرمجة المستعملة ، سوف أضع عينة من الإجابة بلغة السي
وهكذا يكون لديكم فكرة عن كيفية الحل ويمكنكم المواصلة ...وفقكم الله
#include <stdio.h>
#include <stdlib.h>
#Def Max 100
//declaration de l'enregistrement contenant les informtions d'un contact
typedef struct record_agenda{
string[30] prénom;
string[30] nom;
string[1O] tel;//vous pouvez aussi le déclarer en tant que in[1O]
}Record_Agenda;
//la fonction qui ajoute un contact à l'agenda , on lui passe un tableau d'enregistrement et sa taille
le passage d'un tableau est en réference en langage C
void Ajouter_Contact(Record_Agenda agenda[], int taille,string[30]prénom, string nom, string[10] tel)
{
int i=0;
//tester si le tableau est rempli au max
if(taille ==Max ) printf("La taille du tableau est maximale");
else
{
//chercher de la place vide
while(i<taille)
i++;
//à la sortie de la boucle on insère le nouveau record
agenda[i].prénom=prénom;
agenda[i].nom=nom;
agenda[i].tel=tel;
}
//fonction main pour tester
int main()
{
Record_Agenda agenda[Max];
int taille ;
repeat
{
printf("introduire la taille du tableau");
scanf(&taille,"%d");
}
until(taille>0);
//exemple d'ajout
Ajouter_Contact(agenda,taille,mohammed,mohammed,01 23456789);
return(0);
}
والله أعلم.