vikassanmacs
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
#include<stdio.h>
int main()
{
int i,j;
int num2,rem;
int flag;
int arr[3]={1,2,3};
int num;
printf("\nEnter a number:");
scanf("%d",&num);
for(i=0;i<=num;i++)
{
num2=i;
flag=0;
while(num2>0)
{
rem=num2%10;
for(j=0;j<3;j++)
if(rem==arr[j])
{
printf("%3d",i);
flag=1;
}
if(flag)
break;
num2=num2/10;
}
}
return 0;
}
Comment hidden because of low score. Click to expand.
0
of 0 vote
you know what? you are not reversing the string but printing the string in reverse order, this is not desired. but we have to reverse the string element so that there will be a reverse changing in the original string..
- vikassanmacs September 10, 2013Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
I think using Hash set will be better but it requiresextra space,so i will certainly use any O(n*logn) sorting technique to solve this...
- vikassanmacs September 24, 2013