lonelyman
Nouveau membre
S'il vous plait, j'arrive pas calculer la moyenne de chaque étudiant en passant par des fonctions, voilà mon programme, et si vous avez une solution ou un astuce vous me dites
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#define nbet 100
#define nbmat 100
// lecture d'un tableau
void lecture (float v[100][100] )
{
float K[100][100];
int i,j;
int a, b;
{
scanf("%d",&a);
scanf("%d",&b);
for(i=0;i<(a);i++)
{printf("\n vous allez saisir les notes de l'etudiant %d:\n\n",i);
for(j=0;j<(b);j++)
scanf("%f",&K[j]);
printf("----------------------------------------------------------------------");}
system("cls");
}
}
float moyenne(float v[100][100])
{
float V_MG[nbet],s;
int i,j;
int a, b;
for(i=0;i<a;i++)
{s=0.0;
{
for(j=0;j<b;j++)
s+=v[j];
}
V_MG=s/(b);
printf("\nla moyenne de l'etudiant n°%d est:\t%0.2f",i,V_MG);
printf("\n");
}
getch();
return (V_MG);
}
main()
{
int NBet,NBmat;
int choix;
float V[nbet][nbmat], V_MG[nbet];
do{
printf("\n____________________________________________________________________");
printf("\n\n|saisie de donnees \| 1 \|");
printf("\n____________________________________________________________________");
printf("\n\n|releve de notes d'un etudiant \| 2 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Liste des etudiants par ordre de merite \| 3 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Liste des etudiants admis \| 4 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Liste des etudiants non admis \| 5 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Resultats globaux de la promotion \| 6 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Quitter \| 7 \|");
printf("\n____________________________________________________________________");
printf("\n");
printf("Entrer votre choix:");
scanf("%d",&choix);
switch(choix){
case 1: lecture(V);break;
case 2: V_MG[nbet]=moyenne (V);break;
}
}
while (choix!=3);
printf("------------------------------------------------------------------");
getch();
}
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#define nbet 100
#define nbmat 100
// lecture d'un tableau
void lecture (float v[100][100] )
{
float K[100][100];
int i,j;
int a, b;
{
scanf("%d",&a);
scanf("%d",&b);
for(i=0;i<(a);i++)
{printf("\n vous allez saisir les notes de l'etudiant %d:\n\n",i);
for(j=0;j<(b);j++)
scanf("%f",&K[j]);
printf("----------------------------------------------------------------------");}
system("cls");
}
}
float moyenne(float v[100][100])
{
float V_MG[nbet],s;
int i,j;
int a, b;
for(i=0;i<a;i++)
{s=0.0;
{
for(j=0;j<b;j++)
s+=v[j];
}
V_MG=s/(b);
printf("\nla moyenne de l'etudiant n°%d est:\t%0.2f",i,V_MG);
printf("\n");
}
getch();
return (V_MG);
}
main()
{
int NBet,NBmat;
int choix;
float V[nbet][nbmat], V_MG[nbet];
do{
printf("\n____________________________________________________________________");
printf("\n\n|saisie de donnees \| 1 \|");
printf("\n____________________________________________________________________");
printf("\n\n|releve de notes d'un etudiant \| 2 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Liste des etudiants par ordre de merite \| 3 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Liste des etudiants admis \| 4 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Liste des etudiants non admis \| 5 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Resultats globaux de la promotion \| 6 \|");
printf("\n____________________________________________________________________");
printf("\n\n|Quitter \| 7 \|");
printf("\n____________________________________________________________________");
printf("\n");
printf("Entrer votre choix:");
scanf("%d",&choix);
switch(choix){
case 1: lecture(V);break;
case 2: V_MG[nbet]=moyenne (V);break;
}
}
while (choix!=3);
printf("------------------------------------------------------------------");
getch();
}