Computer Science, asked by Army2088, 10 months ago

Puzzle
Raju has a square-shaped puzzle made up of small square pieces containing numbers on them. He wants to rearrange the puzzle by changing the elements of a row into a column element and column element into a row element. Help Raju to solve this puzzle.

Answers

Answered by jyosh357
3

Answer:

#include<iostream>

using namespace std;

int main()

{

 int r,c,i,j;

 int a[10][10];

 cin>>r>>c;

 for(i=0;i<r;i++)

 {

   for(j=0;j<c;j++)

   {

     cin>>a[i][j];

   }

 }

 for(i=0;i<c;i++)

 {

   for(j=0;j<r;j++)

   {

     cout<<a[j][i]<<" ";

   }

   cout<<"\n";

 }

}

Explanation:

Answered by AtulSisodiya
4

Answer:

#include<iostream>

using namespace std;

int main()

{

int r,c,i,j;

 int a[10][10];

 int b[10][10];

int sum[10][10];

 cin>>r>>c;

for(i=0;i<r;i++)

 for(j=0;j<c;j++)

 cin>>a[i][j];

   

for(i=0;i<r;i++)

  for(j=0;j<c;j++)

 cin>>b[i][j];

 for(i = 0; i < r; ++i)

     for(j = 0; j < c; ++j)

         sum[i][j] = a[i][j] + b[i][j];

 

 

 for(i = 0; i < r; ++i)

       for(j = 0; j < c; ++j)

       {

           cout << sum[i][j] << " ";

           if(j == c - 1)

               cout << endl;

       }

}

Explanation:

Take two 2d array input then sum those in another 2d array

Similar questions