Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Move block A Problem 2 (0 / 0)
- 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.
- Example for N = 3 Input:
- 3
- 171328143915410165111761218
- Output:
- 171341016281451117391561218
- #include <stdio.h>
- int main()
- {
- int n,a[50][50],i,j;
- scanf("%d", &n);
- for(i=0;i<n;i++) {
- for(j=0;j<n*2;j++) {
- scanf("%d", &a[i][j]);
- }
- }
- for(i=0;i<n;i++) {
- for(j=0;j<n;j++) {
- printf("%d ", a[i][j]);
- }
- printf("\n");
- }
- for(i=0;i<n;i++) {
- for(j=n;j<n*2;j++) {
- printf("%d ", a[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
- /*
- 3
- 98 80 5 64 78 16
- 19 52 100 37 92 9
- 17 94 46 93 54 86
- 98 80 5
- 19 52 100
- 17 94 46
- 64 78 16
- 37 92 9
- 93 54 86
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement