Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define _USE_MATH_DEFINES
- #include <math.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- #define MAX_ROW 2
- #define MAX_COLUMNS 7
- void read(double[][MAX_COLUMNS]);
- void calc(double[][MAX_COLUMNS], int *, int *);
- void print(double[][MAX_COLUMNS],char[][64], int, int);
- int main(void)
- {
- int i;
- double weather[MAX_ROW][MAX_COLUMNS];
- char days[7][64];
- int min, max;
- for (i = 0; i < 7; i++)
- {
- printf("name of day %d:\n", i);
- gets(days[i]);
- }
- read(weather);
- calc(weather, &min, &max);
- print(weather, days, min, max);
- return 0;
- }
- void read(double a[][MAX_COLUMNS])
- {
- int i, j;
- for (i = 0; i < MAX_ROW; i++)
- {
- for (j = 0; j < MAX_COLUMNS; j++)
- {
- if (i == 0)
- {
- printf("Give temp of day %d: \n", j+1);
- }
- else
- {
- printf("Give temp of night %d: \n", j+1);
- }
- scanf("%lf%*c", &a[i][j]);
- }
- }
- }
- void calc(double a[][MAX_COLUMNS], int *min, int *max)
- {
- int i, j;
- double high, low;
- high = a[0][0];
- low = a[0][0];
- for (i = 0; i < MAX_ROW; i++)
- {
- for (j = 0; j < MAX_COLUMNS; ++j)
- {
- if (high < a[i][j])
- {
- high = a[i][j];
- *max = j;
- }
- if (low > a[i][j])
- {
- low = a[i][j];
- *min = j;
- }
- }
- }
- }
- void print(double a[][MAX_COLUMNS],char dag[][64], int min, int max)
- {
- printf("Min:\tNight:\t%s = %.1lf", dag[min],a[1][min]);
- printf("\n\tDay:\t%s = %.1lf\n", dag[min], a[0][min]);
- printf("Max:\tNight:\t%s = %.1lf", dag[max], a[1][max]);
- printf("\n\tDay:\t%s = %.1lf\n", dag[max], a[0][max]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement