Custom Search
Translate | Print | Email | del.icio.us | A | A | A |

#include <stdio.h>
#include <conio.h>
#define MAX 100
#define MAXX 500
#define WIDTH 10000000


struct dictionary
{
char dic[MAX];
int set;
}ox[MAXX];

struct a
{
char str[MAX];
int set[MAX];
}o;

int fact(int no)
{
if(no==0)
return 1;
else
return no*fact(no-1);
}

int limit;
int counter;

void begin()
{
  FILE *fp1;
  char sp[MAX];
  fp1= fopen("oxford.txt","r");
  rewind(fp1);

  while((fscanf(fp1,"%s\n",sp))!=EOF)
  {
    strcpy(ox[limit].dic,sp);
    ox[limit].set = 0;
    printf("\n\t");
    printf("%s",sp);
    limit++;
  }
  printf("\n\n\tIntializing Data .........\n\n\tTotal Words :: ........\n\n");
  printf("%d",limit);
  
}


void main()
{
int ok=0;
int i,len,seed,a,aa;
char ss[MAX];
int k;
FILE *f;
clrscr();
for(i=0;i<len;i++)
{
o.set[i] =0;
}
begin();

f = fopen("zion.txt","w+");
rewind(f);

printf("\nEnter String :\t");
scanf("%s",o.str);
getch();
//printf(">>=>%d",fact(5));
printf("\n\tProccessing %s .....\n",o.str);
len = strlen(o.str);
aa = fact(len);
printf("\n\tTotal %d Combinations.......\n");
printf("%d",aa);
getch();
a=0;
do
{
a++;
seed=0;
fflush(stdin);
for(i=0;i<len;i++)
{
o.set[i] = 0;
}
ok=0;
printf("\n<%d>\t",a);
fprintf(f,"\n");
do
{
seed = rand()%len;
if((o.set[seed]!=1) && seed <= len)
{
printf("%c ",o.str[seed]);
fprintf(f,"%c",o.str[seed]);
o.set[seed] = 1;
ok++;
}
else
{
continue;
}
}while(ok != len);
if(a%WIDTH == 0)
{
printf("\n\n\tPress Enter to Proceed .........\n\n");
getch();
}


}while( a!=aa);

fclose(f);

f = fopen("zion.txt","r");
rewind(f);
printf("\n\n\tStarting Checker........\n\n");

while((fscanf(f,"%s",ss))!=EOF)
{
for(k=0;k<limit;k++)
{
  if(!strncmp(ss,ox[k].dic,strlen(ox[k].dic)))
  {if(!ox[k].set)
  {
    printf("\n\tMatch Found >=>\t<%d>",++counter);
    printf("\t%s",ox[k].dic);
  
    ox[k].set=1;
  }
  }
}
}
fclose(f);
getch();
printf("\n\n\tEnding Application..........");
getch();
}


O/P:
        Intializing Data .........

        Total Words :: ........425

Enter String :  sherlock

        Proccessing sherlock .....

        Total 1582 Combinations.......

        Starting Grammar Checker........


        Match Found >=> <1>     oh
        Match Found >=> <2>     os
        Match Found >=> <3>     he
        Match Found >=> <4>     her
        Match Found >=> <5>     leo
        Match Found >=> <6>     hero
        Match Found >=> <7>     sore
        Match Found >=> <8>     she
        Match Found >=> <9>     core
        Match Found >=> <10>    shoe
        Match Found >=> <11>    close

--
------------------------~!~----------------------
Best Regards,
G.Arun Bala
B.Tech Information Technology
SSNCE,Kalavakkam
http://dmatriz.wordpress.com
-------------------------~!~---------------------




Comments [Refresh] [ RSS ]