#include<stdio.h>
#include<stdlib.h>
float * somar( float * soma, int qnt, float * media, int * acima_media) {
int i;
float * debitos
= ( float * ) malloc ( qnt
* sizeof ( float ) ) ; for ( i= 0 ; i < qnt; i++ ) {
printf ( "informe o valor em debito da %d%c pessoa\n " , i
+ 1 , 167 ) ; scanf ( "%f" , & debitos
[ i
] ) ; * soma += debitos[ i] ;
}
* media=* soma / qnt;
for ( i= 0 ; i< qnt; i++ ) {
if ( debitos[ i] >* media) {
( * acima_media) ++;
}
}
return debitos;
}
float calcular_maior( float * debitos, int qnt) {
int i;
float maior = debitos[ 0 ] ;
for ( i= 1 ; i < qnt; i++ ) {
if ( debitos[ i] > maior)
maior = debitos[ i] ;
}
return maior;
}
int main( ) {
float media, soma;
int qnt, acima_media = 0 ;
printf ( "informe a quantidade de pessoas a serem fiscalizadas: \n " ) ;
float * debitos = somar( & soma, qnt, & media, & acima_media) ;
float maior = calcular_maior( debitos, qnt) ;
printf ( "a soma de todos os valores: %f\n " , soma
) ; printf ( "a media dos valores: %f\n " , media
) ; printf ( "o maior valor foi: %f\n " , maior
) ; printf ( "a quantidade de pessoas acima da media foi: %d\n " , acima_media
) ;
int i;
for ( i= 0 ; i< qnt; i++ ) {
printf ( " %d valor : %f\n " , i
+ 1 , debitos
[ i
] ) ; }
return 0 ;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CgpmbG9hdCogc29tYXIoZmxvYXQgKnNvbWEsaW50IHFudCwgZmxvYXQgKm1lZGlhLCBpbnQgKmFjaW1hX21lZGlhKXsKICAgIGludCBpOwogICAgZmxvYXQgKmRlYml0b3MgPSAoZmxvYXQqKSBtYWxsb2MgKHFudCpzaXplb2YoZmxvYXQpKTsKICAgIGZvcihpPTA7aSA8IHFudDtpKyspewogICAgICAgIHByaW50ZigiaW5mb3JtZSBvIHZhbG9yIGVtIGRlYml0byBkYSAlZCVjIHBlc3NvYVxuIiwgaSsxLCAxNjcpOwogICAgICAgIHNjYW5m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