0% found this document useful (0 votes)
5 views7 pages

Ins

The document contains a C program that sorts a given string, shifts its characters based on their positions, and filters characters based on certain conditions. It uses a 2D array to track character relationships and implements logic for shifting and unshifting characters. The program includes user input for the string and outputs the sorted, shifted, and filtered characters.

Uploaded by

Karthikeyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Ins

The document contains a C program that sorts a given string, shifts its characters based on their positions, and filters characters based on certain conditions. It uses a 2D array to track character relationships and implements logic for shifting and unshifting characters. The program includes user input for the string and outputs the sorted, shifted, and filtered characters.

Uploaded by

Karthikeyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

void main()

{
int i,j,h=0,l,k=0,count=0,n,s[100][100],t,t1,t2,t3,b[100][100],change[100]
[100],un[100][100];
char name[50],temp;
clrscr();
printf("enter the string:\n");
scanf("%s",name);
n=strlen(name);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
s[i][j]=0;
}
}
for(i=1;i<n;i++)
{
for(j=0;j<i;j++)
{
if(name[j]>name[i])
{
temp=name[j];
name[j]=name[i];
name[i]=temp;
s[i][j]=1;
s[j][i]=1;
}
else
s[i][j]=0;
}
}
printf("\nSorting string is:%s",name);
printf("\nShifting string is:");
for(i=1;i<=n;i++)
{
for(j=0;j<n;j++)
{
t=(name[j]+(i*j));
change[i][j]=t;
if(s[i][j]==1)
{
if(t>=65 &&t<=90)
{
printf("%c",t);
k++;
}
g:while(t>90)
{
t1=(t-90);
if(t1>=65 &&t1<=90)
{
printf("%c",t1);
k++;
}
if(t1>90)
{
t=t1;goto g;
}
while(t1<65)
{
t2=(t1+65);
if(t2>=65 && t2<=90)
{
printf("%c",t2);
k++;
}
break;
}
t=t2;
}
}
else
{
if(t>=65&&t<=90)
{
printf("%c",t);
k++;
}
g1:while(t>90)
{
t1=(t-90);
if(t1>=65 &&t1<=90)
{
printf("%c",t1);
k++;
}
if(t1>90)
{
t=t1;goto g1;
}
while(t1<65)
{
t2=(t1+65);
if(t2>=65 && t2<=90)
{
printf("%c",t2);
k++;
}
break;
}
t=t2;
}
}
}
}
//printf("%d",k);
printf("\n FILTERING CHARCTERS ARE:");
for(i=1;i<n;i++)
{
for(j=0;j<n;j++)
{
if(s[i][j]==0)
{
h=1;
}
}
if(h==1)
{
printf("%c",t);
}
break;
}
for(i=n-1;i>0;i--)
{
for(j=n-1;j>0;j--)
{
t=change[i][j]-(i*j);
un[i][j]=t;
if(s[i][j]==1 && s[j][i]==1)
{
printf("%c",t);
count=count+1;
}
}
if(count==n)
break;
}
printf("\nunshifting string:");
for(i=1;i<n;i++)
{
for(j=0;j<n;j++)
{
t=un[i][j]-(i*j);
if(s[i][j]==1)
{
printf("%d\n",t);
count=count+1;
if(t>=65 &&t<=90)
{
printf("%c",t);
k++;
}
g4:while(t>90)
{
t1=(t-90);
if(t1>=65 &&t1<=90)
{
printf("%c",t1);
k++;
}
if(t1>90)
{
t=t1;goto g4;
}
while(t1<65)
{
t2=(t1+65);
if(t2>=65 && t2<=90)
{
printf("%c",t2);
k++;
}
break;
}
t=t2;
}
}
if(count==n)
break;
}
}
getch();
}

void main()
{
int i,j,h=0,l,k=0,count=0,n,s[100][100],t,t1,t2,t3,b[100][100],change[100]
[100],un[100][100];
char name[50],temp;
clrscr();
printf("enter the string:\n");
scanf("%s",name);
n=strlen(name);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
s[i][j]=0;
}
}
for(i=1;i<n;i++)
{
for(j=0;j<i;j++)
{
if(name[j]>name[i])
{
temp=name[j];
name[j]=name[i];
name[i]=temp;
s[i][j]=1;
s[j][i]=1;
}
else
s[i][j]=0;
}
}
printf("\nSorting string is:%s",name);
printf("\nShifting string is:");
for(i=1;i<=n;i++)
{
for(j=0;j<n;j++)
{
t=(name[j]+(i*j));
change[i][j]=t;
if(s[i][j]==1)
{
if(t>=65 &&t<=90)
{
printf("%c",t);
k++;
}
g:while(t>90)
{
t1=(t-90);
if(t1>=65 &&t1<=90)
{
printf("%c",t1);
k++;
}
if(t1>90)
{
t=t1;goto g;
}
while(t1<65)
{
t2=(t1+65);
if(t2>=65 && t2<=90)
{
printf("%c",t2);
k++;
}
break;
}
t=t2;
}
}
else
{
if(t>=65&&t<=90)
{
printf("%c",t);
k++;
}
g1:while(t>90)
{
t1=(t-90);
if(t1>=65 &&t1<=90)
{
printf("%c",t1);
k++;
}
if(t1>90)
{
t=t1;goto g1;
}
while(t1<65)
{
t2=(t1+65);
if(t2>=65 && t2<=90)
{
printf("%c",t2);
k++;
}
break;
}
t=t2;
}
}
}
}
//printf("%d",k);
printf("\n FILTERING CHARCTERS ARE:");
for(i=1;i<n;i++)
{
for(j=0;j<n;j++)
{
if(s[i][j]==0)
{
h=1;
}
}
if(h==1)
{
printf("%c",t);
}
break;
}
for(i=n-1;i>0;i--)
{
for(j=n-1;j>0;j--)
{
t=change[i][j]-(i*j);
un[i][j]=t;
if(s[i][j]==1 && s[j][i]==1)
{
printf("%c",t);
count=count+1;
}
}
if(count==n)
break;
}
printf("\nunshifting string:");
for(i=1;i<n;i++)
{
for(j=0;j<n;j++)
{
t=un[i][j]-(i*j);
if(s[i][j]==1)
{
printf("%d\n",t);
count=count+1;
if(t>=65 &&t<=90)
{
printf("%c",t);
k++;
}
g4:while(t>90)
{
t1=(t-90);
if(t1>=65 &&t1<=90)
{
printf("%c",t1);
k++;
}
if(t1>90)
{
t=t1;goto g4;
}
while(t1<65)
{
t2=(t1+65);
if(t2>=65 && t2<=90)
{
printf("%c",t2);
k++;
}
break;
}
t=t2;
}
}
if(count==n)
break;
}
}
getch();
}

You might also like