Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define ROW 3
- #define COLUMNS 5
- void input_date(double **);
- void output_date(double **);
- void avr(double **);
- void max_in_array(double**);
- void free_array(double **);
- int main(void)
- {
- double **array;
- array = (double**)malloc(sizeof(double*)*ROW);
- input_date(array);
- system("clear");
- output_date(array);
- putchar('\n');
- avr(array);
- max_in_array(array);
- }
- void input_date(double **array)
- {
- //array = (double*)malloc(sizeof(double)*ROW*COLUMNS);
- for(int i = 0;i<ROW;i++){
- printf("введите значения для %d строки \n",i+1);
- *(array+i)= (double*)malloc(sizeof(double)*COLUMNS);
- for(int j = 0; j<COLUMNS;j++){
- printf("%d = ",j+1);
- scanf("%lf",&*(*(array+i)+j));
- }
- }
- }
- void output_date(double **array)
- {
- for(int i = 0;i < ROW;i++){
- for(int j = 0;j <COLUMNS;j++)
- printf("%5.2lf ",array[i][j]);
- putchar('\n');
- }
- }
- void avr(double **array)
- {
- double avr,avr_all ;
- for(int i =0; i < ROW;i++){
- avr=0;
- for(int j =0 ; j<COLUMNS;j++)
- avr+=*(*(array+i)+j);
- printf("Среднее значение для %d линии = %.2lf\n",i,avr/COLUMNS);
- avr_all+=avr;
- }
- printf("Среднее значение для всех линии = %.2lf\n",avr_all/ROW);
- }
- void max_in_array(double **array)
- {
- double max = *(*(array+0)+0);
- for(int i =0;i<ROW;i++)
- for(int j = 0;j<COLUMNS;j++)
- if(max < *(*(array+i)+j))
- max = *(*(array+i)+j);
- printf("Наибольшее значени - %.2lf\n",max);
- }
- void free_array(double **array)
- {
- for(int i =0;i<ROW;i++)
- free(*(array+i));
- free(array);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement