TP 1 Ex:9(a,b,c,d)

Exercice 9 a-b:
#include <stdio.h>

void main(void) {
int i,n,note,tot=0,min,max;
int t[24];
/* on peut faire sans tableau voir ci dessous (c-d) */

printf("Combien de notes ?\n");
do {
scanf("%d",&n);
}while((n<0) || (n>25));

for(i=0;i<n;i++){
do {
printf("note %d°\n",i+1);
scanf("%d",&note);
}while((note<0) || (note>20));
t[i]=note;
}

min=20;
max=0;
for(i=0;i<n;i++){
tot+=t[i];
if (t[i]<min)
min=t[i];
if (t[i]>max)
max=t[i];
printf("%d,",t[i]);
}

printf("\n\nnote maxi: %d\nnote mini: %d\nmoyenne: %f\n",max,min,(float) (tot/n));
printf("\nFin du programme.\n");
/* ©2002 All Rights reserved to www.Software-DS.com */
}


Exercice 9 c-d:
#include <stdio.h>

void main(void) {
int i,n;
float coeff,min=20,max=0,note,tot=0,tot_coeff=0;

printf("Combien de notes ?\n");
do {
scanf("%d",&n);
}while((n<0) || (n>25));

for(i=0;i<n;i++){
do {
printf("note %d°\n",i+1);
scanf("%f",&note);
}while((note<0) || (note>20));
do {
printf("coeff %d\n",i+1);
scanf("%f",&coeff);
}while(coeff<0);
tot+=coeff*note;
tot_coeff+=coeff;
if (note<min)
min=note;
if (note>max)
max=note;
}
tot/=tot_coeff;
printf("\n\nnote maxi: %f\nnote mini: %f\nmoyenne: %f\n",max,min,tot);
if (tot<10)
printf("\ninsuffisant !\n");
else if (tot<12)
printf("\npassable.\n");
else if (tot<14)
printf("\nassez bien.\n");
else if (tot<16)
printf("\nbien.\n");
else if (tot<18)
printf("\ntres bien.\n");
else printf("\nExcellent, Didier STRAUS est de votre famille ?\n");

printf("\nFin du programme.\n");
/* ©2002 All Rights reserved to www.Software-DS.com 29/01/2002 */
}






Haut de la page - Page générée en 0.02970 sec.
 

1847337 visiteurs.   ©2001-2024 All Rights Reserved to Software-DS.com
Made with a mac  
Confidentialité