Advertisement
Guest User

Untitled

a guest
May 6th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define ROW 3
  5. #define COLUMNS 5
  6.  
  7. void input_date(double **);
  8. void output_date(double **);
  9. void avr(double **);
  10. void max_in_array(double**);
  11. void free_array(double **);
  12.  
  13. int main(void)
  14. {
  15. double **array;
  16. array = (double**)malloc(sizeof(double*)*ROW);
  17.  
  18. input_date(array);
  19. system("clear");
  20. output_date(array);
  21. putchar('\n');
  22. avr(array);
  23. max_in_array(array);
  24.  
  25.  
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  
  32. void input_date(double **array)
  33. {
  34. //array = (double*)malloc(sizeof(double)*ROW*COLUMNS);
  35.  
  36. for(int i = 0;i<ROW;i++){
  37. printf("введите значения для %d строки \n",i+1);
  38. *(array+i)= (double*)malloc(sizeof(double)*COLUMNS);
  39. for(int j = 0; j<COLUMNS;j++){
  40. printf("%d = ",j+1);
  41. scanf("%lf",&*(*(array+i)+j));
  42. }
  43. }
  44. }
  45.  
  46. void output_date(double **array)
  47. {
  48. for(int i = 0;i < ROW;i++){
  49. for(int j = 0;j <COLUMNS;j++)
  50. printf("%5.2lf ",array[i][j]);
  51.  
  52. putchar('\n');
  53. }
  54. }
  55.  
  56. void avr(double **array)
  57. {
  58. double avr,avr_all ;
  59. for(int i =0; i < ROW;i++){
  60. avr=0;
  61. for(int j =0 ; j<COLUMNS;j++)
  62. avr+=*(*(array+i)+j);
  63. printf("Среднее значение для %d линии = %.2lf\n",i,avr/COLUMNS);
  64. avr_all+=avr;
  65.  
  66. }
  67. printf("Среднее значение для всех линии = %.2lf\n",avr_all/ROW);
  68. }
  69.  
  70. void max_in_array(double **array)
  71. {
  72. double max = *(*(array+0)+0);
  73.  
  74. for(int i =0;i<ROW;i++)
  75. for(int j = 0;j<COLUMNS;j++)
  76. if(max < *(*(array+i)+j))
  77. max = *(*(array+i)+j);
  78.  
  79. printf("Наибольшее значени - %.2lf\n",max);
  80. }
  81.  
  82. void free_array(double **array)
  83. {
  84. for(int i =0;i<ROW;i++)
  85. free(*(array+i));
  86. free(array);
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement