Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <conio.h>
  4. #define n 5
  5. #define m 4
  6.  
  7. int main () {
  8.     int i, j, n_max = 0;
  9.     float a[n][m], cache_max = 0.0;
  10.     printf("Input array a\n");
  11.     for(i = 0; i < n; i++) {
  12.         for(j = 0; j < m; j++) {
  13.             scanf("%f", &a[i][j]);
  14.             if(a[i][j] > cache_max) {
  15.                 n_max = i;
  16.                 cache_max = a[i][j];
  17.             }
  18.         }
  19.     }
  20.     float a1[m], b[m];
  21.     for(i = 0; i < m; i++) {
  22.         a1[i] = a[n_max][i];
  23.         b[i] = sin(a1[i]) + cos(a1[i]);
  24.     }
  25.     float cache;
  26.     for(i = 0; i < m; i++) {
  27.         if(i % 2 == 0) {
  28.             j = i - 1;
  29.             cache = a1[i]
  30.             a1[i] = a1[j];
  31.             a1[j] = cache;
  32.             cache = b[i]
  33.             b[i] = b[j];
  34.             b[j] = cache;
  35.         }
  36.     }
  37.     printf("Output array a1\n");
  38.     for(i = 0; i < m; i++) {
  39.         printf("%.1f", a1[i];
  40.     }
  41.     printf("Output array b\n");
  42.     for(i = 0; i < m; i++) {
  43.         printf("%.1f", b[i];
  44.     }
  45.     getch();
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement