navin9876
BAN USER1> Length of the sentence entered is computed [i]
2> then we select every character of the sentence one by one going from left to right
3> Each selected character is then matched by every character of the sentence in the reverse order ( going right to left)
4> when a match occurs, the match is made for the next Character going left to right with the next character after match from right to length.
5> The number of matches ie length of palindrome is computed.
6> It is compared to previous max length of palindrome, and hence the longest palindrome is found and printed.
P.S.- I wrote the code in hurry so I didnt use meaningful variable, but I hav tested it and it runs work successfully giving the desired reslt.
# include <stdio.h>
# include <conio.h>
void main()
{
clrscr();
int i=0,j,even[15],odd[15],t,e=0,o=0;
printf("\n Enter 15 numbers\n");
while (i<15)
{
scanf("%d",&j);
if (j%2 == 0)
{
even[e]=j;
e=e+1;
}
else
{
odd[o]=j;
o=o+1;
}
i=i+1;
}
for (i=0;i<o;i++)
{
for (j=i+1;j<=o;j++)
{
if (odd[i] < odd[j])
{
t=odd[i];
odd[i]=odd[j];
odd[j]=t;
}
}
}
printf("\n The sorted list odd descending and even ascending:\n ");
for (i=0;i<e;i++)
{
for (j=i+1;j<=e;j++)
{
if (even[i] > even[j])
{
t=even[i];
even[i]=even[j];
even[j]=t;
}
}
}
for (i=0;i<o;i++)
{
printf("%d ",odd[i]);
}
for (i=0;i<e;i++)
{
printf("%d ",even[i]);
}
}
# include<stdio.h>
# include <conio.h>
void main()
{
char line[90];
int i=0,j,k,c,l=0,n=0,t=0,st;
clrscr();
printf("Enter a sentence ");
gets (line);
while (line[i]!='\0')
{
i=i+1;
}
while (l<i)
{
j=i-1;
k=l;
c=0;
while (j>l)
{
if (line[j]==line[k])
{
while (line[j]==line[k])
{
j=j-1;
k=k+1;
c=c+1;
}
if (t<c)
{
st=l;
t=c-1;
} }
j=j-1;
}
l=l+1;
}
printf("\n The longest palindrome is : \n");
while (n<t)
{
printf("%c",line[st+n]);
n=n+1;
}
}
# include <stdio.h>
# include <conio.h>
void main()
{
int a[6],i;
printf("\n Enter the digits (1-9)");
for (i=0; i<3; i++)
{
scanf("%d",&a[i]);
a[i+3]=a[i];
}
printf("\n All possible numbers using given digits are \n");
for (i=0; i< 3; i=i+1)
{
printf("%d ",a[i]);
printf("%d%d ",a[i],a[i+1]);
printf("%d%d ",a[i],a[i+2]);
printf("%d%d%d ",a[i],a[i+1],a[i+2]);
printf("%d%d%d ",a[i],a[i+2],a[i+1]);
}
}
# include<stdio.h>
# include <conio.h>
void main()
{
int i=0,j=0;
char widspc[80],wospc[80];
printf("\n Enter A string with blank spaces: ");
gets(widspc);
while (widspc[i]!='\0')
{
if (widspc[i] != ' ')
{
wospc[j]=widspc[i];
j=j+1;
}
i=i+1;
}
wospc[j+1]='\0';
printf("\n");
puts(wospc);
}
I ll prefer a single class only if the company's distrbution system is highly centeralised, bt if the company has several distribution branches around the world.........i ll have seperate class for each branch which will b called depending on its closeness frm the customer's location.
- navin9876 August 18, 2010