idastan97

CSCI151 L17 P4

Sep 29th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. /*
  2.  * prog.c
  3.  *
  4.  *  Created on: Sep 29, 2016
  5.  *      Author: dastan.iyembergen
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. void transpose(int row, int col, double orig[row][col], double result[col][row]){
  11.     int i, j;
  12.     for (i=0; i<row; i++){
  13.         for (j=0; j<col; j++){
  14.             result[j][i]=orig[i][j];
  15.         }
  16.     }
  17. }
  18.  
  19. void printArr(int row, int col, double arr[row][col]){
  20.     int i, j;
  21.     for (i=0; i<row; i++){
  22.         for (j=0; j<col; j++){
  23.             printf("%5f ", arr[i][j]);
  24.         }
  25.         printf("\n");
  26.     }
  27. }
  28.  
  29. int main(){
  30.     double orig[2][3]={{53.2, 546.2, 9},
  31.                        {2.5, 5.6, 11}
  32.     };
  33.     double result[3][2];
  34.     transpose(2, 3, orig, result);
  35.     printArr(3, 2, result);
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment