Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Move block A Problem 2 (0 / 0)
  2. Write a program that will read matrix of integers A with N rows and N * 2 columns (N is not larger than 50). The program should transform the read matrix into a new matrix B, so that all elements right from the N-th column will move bellow the N-th row, so that the matrix A with dimensions of N rows and N * 2 columns, will be transformed into matrix B with dimensions N * 2 rows and N columns.
  3.  
  4. Example for N = 3 Input:
  5.  
  6. 3
  7.  
  8. 171328143915410165111761218
  9. Output:
  10. 171341016281451117391561218
  11.  
  12. #include <stdio.h>
  13. int main()
  14. {
  15. int n,a[50][50],i,j;
  16. scanf("%d", &n);
  17. for(i=0;i<n;i++) {
  18. for(j=0;j<n*2;j++) {
  19. scanf("%d", &a[i][j]);
  20. }
  21. }
  22. for(i=0;i<n;i++) {
  23. for(j=0;j<n;j++) {
  24. printf("%d ", a[i][j]);
  25. }
  26. printf("\n");
  27. }
  28.  
  29. for(i=0;i<n;i++) {
  30. for(j=n;j<n*2;j++) {
  31. printf("%d ", a[i][j]);
  32. }
  33. printf("\n");
  34. }
  35.  
  36. return 0;
  37. }
  38.  
  39. /*
  40. 3
  41. 98 80 5 64 78 16
  42. 19 52 100 37 92 9
  43. 17 94 46 93 54 86
  44.  
  45. 98 80 5
  46. 19 52 100
  47. 17 94 46
  48. 64 78 16
  49. 37 92 9
  50. 93 54 86
  51. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement