is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
#include<stdio.h>
- mkumarsoni75 April 26, 2015int check_pow(int n){
int k=2;
if(n<=2048 && n>=2){
while(k<=n){
if(k==n) // validate the value for power of two
return 1;
k=k*2;
}
return 0;
}
else if(n==0)
return 1;
else
return 0;
}
main()
{
int a[10][10];
int b[10][10];
int n;
int r=0,c=0;
int max1=0,max2=0;
int temp=0;
while(1){
scanf("%d",&temp);
if(temp<2 || temp>10)
{
printf("~~~~~ please enter the valide range \n ~~~~~(VALUE SHOULD BE IN BETWEEN 2 AND 10 INCLUDEING BOTH 2 AND 10)\n");
}
else
{
n=temp;
break;
}
}
printf(" enter data to the grid \n");
for(c=0;c<n;++c){
for(r=0;r<n;){
scanf("%d",&temp);
if(check_pow(temp))
{
a[c][r]=temp;
b[c][r]=temp;
++r;
}
else
{
printf(">>>>>%d is not a valide number (NOT A POWER OF TWO) \n>>>>>please enter the valide value\n",temp);
}
}
}
//for left move
for(c=0;c<n;++c){
for(r=n-1;r>0;r=r-1){
if(a[c][r-1] == 0 )
{
a[c][r-1]=a[c][r];
a[c][r]=0;
r=r-1;
}
else if(a[c][r-1] == a[c][r])
{
a[c][r-1]=a[c][r]+a[c][r-1];
a[c][r]=0;
if( a[c][r-2]==0)
r=r-1;
// printf("%d",a[c][r-1]);
}
}
}
// for right move
for(c=0;c<n;++c){
for(r=0;r<n-1;r=r+1){
if(b[c][r+1] == 0 )
{
b[c][r+1]=b[c][r];
b[c][r]=0;
r=r+1;
}
else if(b[c][r+1] == b[c][r])
{
b[c][r+1]=b[c][r]+b[c][r+1];
b[c][r]=0;
if( b[c][r+2]==0)
r=r+1;
// printf("%d",a[c][r-1]);
}
}
}
/* for(c=0;c<n;++c){
for(r=n-1;r>0;r=r-1){
}
}
*/
printf(" *************** LEFT MOVE ************************* \n");
for(c=0;c<n;++c){
for(r=0;r<n;++r){
if(a[c][r]>max1)
max1=a[c][r];
printf("%d\t",a[c][r]);
}
printf("\n");
}
printf(" **************** RIGHT LEFT ************************ \n");
for(c=0;c<n;++c){
for(r=0;r<n;++r){
if(b[c][r]>max2)
max2=b[c][r];
printf("%d\t",b[c][r]);
}
printf("\n");
}
if(max1>max2)
printf("MAX VALUE = %d",max1);
else
printf("MAX VALUE = %d",max2);
}