Najva1989
چهارشنبه 09 دی 1388, 20:00 عصر
اين برنامه يه سري لغات رو به عناون فرهنگ لغت داخل يه درخت bst مي كنه و بعد يه متن رو گرفته و لغاتي رو كه داخل فرهنگ لغت نيستند رو مشخص مي كنه
حالا من هر كاري مي كنم ++c ارور مي ده
مشكل كجاست؟؟؟:گریه:
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
struct node
{
char info[20];
node *left;
node *right;
}
node *insert(node *p,char x[20])
{
if (p==null)
{
p=new node;
p->info=x;
p->left= p->right =null;
}
else
{
node *help=p;
while(help!=null)
{
if(x > help->info)
{
if(help->right!=null)
help=help->right;
else
{
node *help1 = help->right;
help1=new node;
help1->info=x;
help1->left = help1->right = null;
}
}
else
{
if(help->left!=null)
help=help->left;
else
{
node *help1 = help->left;
help1=new node;
help1->info=x;
help1->left = help1->right = null;
}
}
}
}
return(p);
}
void comp(node*p,char x[20])
{
node *help=p;
while(help!=null)
{
if(strcmp(x,help->info)>0)
help=help->right;
else if (strcmp(x,help->info)<0)
help=help->left;
else
cout<<"word is in the dictionary.\n";
}
if(help=p && !strcmp(x,help->info))
cout<<"word isn't in the dictionary.\n";
}
main()
{
int i,j;
char x[20];f[20];s[100];
node first=null;
cout<<"enter the number of word for dictionary.\n";
cin>>n;
cout<<"enterthe word of dictionary.\n";
while(n-->0)
{
gets(f);
insert(first,f[20]);
}
cout<<"enter your text\n";
gets(s);
for (i=0;s[i];i++)
{
if (s[i]==" ")
{
j=0;
while (s[i]!=" ")
{
x[j]=s[i];
j++;
}
comp(first,x[20]);
}
}
getch();
}
حالا من هر كاري مي كنم ++c ارور مي ده
مشكل كجاست؟؟؟:گریه:
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
struct node
{
char info[20];
node *left;
node *right;
}
node *insert(node *p,char x[20])
{
if (p==null)
{
p=new node;
p->info=x;
p->left= p->right =null;
}
else
{
node *help=p;
while(help!=null)
{
if(x > help->info)
{
if(help->right!=null)
help=help->right;
else
{
node *help1 = help->right;
help1=new node;
help1->info=x;
help1->left = help1->right = null;
}
}
else
{
if(help->left!=null)
help=help->left;
else
{
node *help1 = help->left;
help1=new node;
help1->info=x;
help1->left = help1->right = null;
}
}
}
}
return(p);
}
void comp(node*p,char x[20])
{
node *help=p;
while(help!=null)
{
if(strcmp(x,help->info)>0)
help=help->right;
else if (strcmp(x,help->info)<0)
help=help->left;
else
cout<<"word is in the dictionary.\n";
}
if(help=p && !strcmp(x,help->info))
cout<<"word isn't in the dictionary.\n";
}
main()
{
int i,j;
char x[20];f[20];s[100];
node first=null;
cout<<"enter the number of word for dictionary.\n";
cin>>n;
cout<<"enterthe word of dictionary.\n";
while(n-->0)
{
gets(f);
insert(first,f[20]);
}
cout<<"enter your text\n";
gets(s);
for (i=0;s[i];i++)
{
if (s[i]==" ")
{
j=0;
while (s[i]!=" ")
{
x[j]=s[i];
j++;
}
comp(first,x[20]);
}
}
getch();
}