Advertisement
Guest User

Untitled

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