===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
long i,j,k,len,repeat[40],N,TT,LEN,z,x,y,T,t,q;
char str[40],c,STR[40],a[40],s[2];
textcolor(WHITE);
cprintf("Enter Your Name: ");
gets(str);
//Finding Lenght
for(i=0;str[i]!='\0';i++);
len=i-1;
LEN=len;
//Capitalization and storing array
for(i=0;i<=len+1;i++)
{
if(str[i]>=97 && str[i]<=122)
str[i]=str[i]-32;
STR[i]=str[i];
}
STR[i]='\0';
//Arranging
for(i=0;i<=len-1;i++)
{
for(j=0;j<=len-i-1;j++)
{
if(str[j]>str[j+1])
{
c=str[j+1];
str[j+1]=str[j];
str[j]=c;
}
}
}
//Temporary storing, Counting and Deleteing
for(i=0,z=0;i<=len;)
{
a[z]=str[i];
for(j=i,k=0;j<=len;j++,k++)
{
if(str[i]!=str[j])
break;
}
repeat[z]=k;
z++;
i+=k;
}
a[z]='\0';
//Finding New Length and Again storing
for(i=0;a[i]!='\0';i++)
{
str[i]=a[i];
}
str[i]='\0';
len=i-1;
//Counting Total Alphabets
for(i=0,TT=0;i<=len;i++)
TT+=repeat[i];
//Factorizing Total Without Repeatation
for(i=TT,TT=1;i>=2;i--)
TT*=i;
//Finding all Possible combinations by removing Repeatetions
for(i=0;i<=len;i++)
{
N=repeat[i];
for(j=N,N=1;j>=2;j--)
N*=j;
TT/=N;
}
cout<<"\n";
//Finding Name in its Dictionary
for(i=0,q=0,t=0;i<=LEN;i++)
{
for(j=0;j<=len;j++)
{
if(repeat[j]==0)
continue;
if(STR[i]==str[j])
{
repeat[j]-=1;
break;
}
else
{
repeat[j]-=1;
for(x=0,T=0;x<=len;x++)
T+=repeat[x];
for(x=T,T=1;x>=2;x--)
T*=x;
for(x=0;x<=len;x++)
{
N=repeat[x];
for(y=N,N=1;y>=2;y--)
N*=y;
T/=N;
}
repeat[j]+=1;
t+=T;
textcolor(RED);
for(x=0;x<q;x++)
cprintf("%c",STR[x]);
textcolor(CYAN);
cprintf("%c",str[j]);
textcolor(WHITE);
cprintf(" =>%ld\n\r",T);
}
}
q++;
}
textcolor(RED);
cprintf("%s\n\r",STR);
t+=1;
switch(t)
{
case 1: strcpy(s,"st"); break;
case 2: strcpy(s,"nd"); break;
case 3: strcpy(s,"rd"); break;
default: strcpy(s,"th");
}
textcolor(WHITE);
cprintf("\n\n\r\"%s\" occupies %ld%s position in its Dictionary of %ld words",STR,t,s,TT);
getch();
}
CODING
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
long i,j,k,len,repeat[40],N,TT,LEN,z,x,y,T,t,q;
char str[40],c,STR[40],a[40],s[2];
textcolor(WHITE);
cprintf("Enter Your Name: ");
gets(str);
//Finding Lenght
for(i=0;str[i]!='\0';i++);
len=i-1;
LEN=len;
//Capitalization and storing array
for(i=0;i<=len+1;i++)
{
if(str[i]>=97 && str[i]<=122)
str[i]=str[i]-32;
STR[i]=str[i];
}
STR[i]='\0';
//Arranging
for(i=0;i<=len-1;i++)
{
for(j=0;j<=len-i-1;j++)
{
if(str[j]>str[j+1])
{
c=str[j+1];
str[j+1]=str[j];
str[j]=c;
}
}
}
//Temporary storing, Counting and Deleteing
for(i=0,z=0;i<=len;)
{
a[z]=str[i];
for(j=i,k=0;j<=len;j++,k++)
{
if(str[i]!=str[j])
break;
}
repeat[z]=k;
z++;
i+=k;
}
a[z]='\0';
//Finding New Length and Again storing
for(i=0;a[i]!='\0';i++)
{
str[i]=a[i];
}
str[i]='\0';
len=i-1;
//Counting Total Alphabets
for(i=0,TT=0;i<=len;i++)
TT+=repeat[i];
//Factorizing Total Without Repeatation
for(i=TT,TT=1;i>=2;i--)
TT*=i;
//Finding all Possible combinations by removing Repeatetions
for(i=0;i<=len;i++)
{
N=repeat[i];
for(j=N,N=1;j>=2;j--)
N*=j;
TT/=N;
}
cout<<"\n";
//Finding Name in its Dictionary
for(i=0,q=0,t=0;i<=LEN;i++)
{
for(j=0;j<=len;j++)
{
if(repeat[j]==0)
continue;
if(STR[i]==str[j])
{
repeat[j]-=1;
break;
}
else
{
repeat[j]-=1;
for(x=0,T=0;x<=len;x++)
T+=repeat[x];
for(x=T,T=1;x>=2;x--)
T*=x;
for(x=0;x<=len;x++)
{
N=repeat[x];
for(y=N,N=1;y>=2;y--)
N*=y;
T/=N;
}
repeat[j]+=1;
t+=T;
textcolor(RED);
for(x=0;x<q;x++)
cprintf("%c",STR[x]);
textcolor(CYAN);
cprintf("%c",str[j]);
textcolor(WHITE);
cprintf(" =>%ld\n\r",T);
}
}
q++;
}
textcolor(RED);
cprintf("%s\n\r",STR);
t+=1;
switch(t)
{
case 1: strcpy(s,"st"); break;
case 2: strcpy(s,"nd"); break;
case 3: strcpy(s,"rd"); break;
default: strcpy(s,"th");
}
textcolor(WHITE);
cprintf("\n\n\r\"%s\" occupies %ld%s position in its Dictionary of %ld words",STR,t,s,TT);
getch();
}
===========================================================================
No comments:
Post a Comment