Skip to main content

Zoho Interview | Set 5 (On-Campus Drive)


 
 
 
#include<stdio.h>
#include<conio.h>

#define N 6

void display(int a[N][N]){
int i,j;
for(i=0;i<N;i++){
 for(j=0;j<N;j++)
  printf("%4d",a[i][j]);
 printf("\n\n");
}

}

void rotateMatrix(int a[N][N], int b[N][N]){

int i,j,temp,times,end,start;
times = 0;
end = N-1;
start = 0;
temp = N/2;
 while(times < temp){
 i = j = times;

  b[i][j++] = a[i+1][j];
  while( j < end ){
   b[i][j++] = a[i][j-1];
  }
  b[i++][j] = a[i][j-1];


  while( i < end ){
   b[i++][j] = a[i-1][j];
  }

  b[i][j--] = a[i-1][j];
  while( j > start ){
   b[i][j--] = a[i][j+1];
  }

  b[i--][j] = a[i][j+1];
  while( i > start ){
   b[i--][j] = a[i+1][j];
  }
 times++;
 end--;
 start++;
 }

}

int main(){
int a[N][N],i,j,b[N][N],k;
clrscr();

memset(b, 0, sizeof(b));

k = 1;
for(i=0;i<N;i++)
 for(j=0;j<N;j++)
  a[i][j] = k++;

display(a);
rotateMatrix(a, b);
printf("\n\nAfter the Rotate...\n\n\n");
display(b);
getch();
return 0;
}

Comments

Post a Comment

Popular posts from this blog

ORACLE 9i practice solutions

Created by BCL easyConverter SDK 3 (HTML Version)

Zoho Puzzle Questions With Answers

Measuring Time Logic Puzzle You are given with two ropes with variable width. However if we start burning both the ropes, they will burn at exactly same time i.e. an hour. The ropes are non-homogeneous in nature. You are asked to measure 45 minutes by using these two ropes.

How can you do it?

Please note that you can’t break the rope in half as it is being clearly stated that the ropes are non-homogeneous in nature.
Answer & Explanation Solution: 45 minutes

Explanation :
All you have to do is burn the first rope from both the ends and the second rope from one end only simultaneously. The first rope will burn in 30 minutes (half of an hour since we burned from both sides) while the other rope would have burnt half. At this moment, light the second rope from the other end as well. Where, the second rope would have taken half an hour more to burn completely, it will take just 15 minutes as we have lit it from the other end too.

Thus you have successfully calculated 30+15 = 45 minutes …

Hackerrank > SQL > Basic Select

Select
01-Select All
Given a City table, whose fields are described as +-------------+----------+ | Field       | Type     | +-------------+----------+ | ID          | int(11)  | | Name        | char(35) | | CountryCode | char(3)  | | District    | char(20) | | Population  | int(11)  | +-------------+----------+
write a query that will fetch all columns for every row in the table.

My Solution
SELECT*FROM city;
---------------------------------------------------------------------------------
02-Select by ID
Given a City table, whose fields are described as