Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define SETTIMANA 7
- #define SOGGETTI 5
- void CalorieObesi(float calor[SOGGETTI][SETTIMANA]);
- void totaleCalorie(float calor[SOGGETTI][SETTIMANA]);
- int main(int argc, char *argv[]) {
- float calorie[SOGGETTI][SETTIMANA]={0};
- float media_calorie;
- CalorieObesi(calorie);
- totaleCalorie(calorie);
- return 0;
- }
- void CalorieObesi(float calor[SOGGETTI][SETTIMANA]){
- int i, k;
- for (i=0; i<SETTIMANA; i++){
- printf("--GIORNO %d--\n", i+1);
- for(k=0; k<SOGGETTI; k++){
- printf("Inserisca le calorie del soggetto %d: \t\t", k+1);
- scanf("%f", &calor[k][i]);
- }
- }
- }
- void totaleCalorie(float calor[SOGGETTI][SETTIMANA]){
- int i, k=0;
- float totale=0;
- for(i=0;i<SOGGETTI; i++){
- printf("--SOGGETTO %d--\n",i+1);
- printf("--Calcolo totale calorie del soggetto %d\n", k+1);
- for(k=0; k<SETTIMANA;k++){
- totale=totale+calor[i][k];
- }
- printf("TOTALE CALORIE SETTIMANA: %.2lf\n", totale);
- printf("MEDIA CALORIE ASSUNTE NELLA SETTIMANA: %.2lf\n", totale/7);
- printf("------------------------\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement