//it sometimes crashes sometimes not why?
#include<iostre am>
#include<fstrea m>
#include<vector >
#include<string >
#include<ctime>
using namespace std;
#ifndef NULL
#define NULL (short) 0
#endif
char
*words[53]={"come","garde n","one","nice" ,"go","we","som e","where","old ",
"days","who","b ilir","where"," school","eat"," apple","look"," ayy","see","eye ","haha",
"birds","fly"," come", "me", "can","sugar"," laugh","ss", "ad", "asad",
"digf","you ",
"know", "burn","ah ahh","desk","ic e", "look",
"hand","cry","b lood","goes","w ar",
"loop","open"," pass","throw"," age","monkey"," doom","hobaa"};
//*************** ****node class********** *********
class node{
private:
string word;
node *next;
public:
node()
{
next=NULL;
}
friend class list;
void display()
{
cout<<word<<" ";
}
};
//*************** **list class********** ***********
class list{
private:
node *head,*tail,*TO P;
void append(node *new_node);
public:
list()
{
TOP=new node;
head=tail=TOP;
TOP->next=NULL;
}
~list()
{
node *ptr=head;
while(ptr)
{
node *tmp=ptr;
ptr=ptr->next;
delete tmp;
}
head=tail=TOP=N ULL;
}
void getWords();
void displayAll();
};
void list::displayAl l()
{
node *py;
py=head;
if(py==NULL)
{
cout<<"nothing to show"<<endl;
}
while(py!=NULL)
{//while py points sth reasonable
py->display();
py=py->next;
}
}
void list::append(no de *ptr){
if(TOP->next==NULL)//first element
{ TOP->next=ptr;
head=ptr;
tail=ptr;
}
else
{
tail->next=ptr;
tail=ptr;
}
}
void list::getWords( )
{ int num;
srand((unsigned )time( NULL ));
for(int m=0;m<50;m++)
{
num=(rand()%53) ;
node *object;
object=new node;
object->word=words[num];
append(object);
}
}
void main()
{
list thelist;
thelist.getWord s();
thelist.display All();
}
#include<iostre am>
#include<fstrea m>
#include<vector >
#include<string >
#include<ctime>
using namespace std;
#ifndef NULL
#define NULL (short) 0
#endif
char
*words[53]={"come","garde n","one","nice" ,"go","we","som e","where","old ",
"days","who","b ilir","where"," school","eat"," apple","look"," ayy","see","eye ","haha",
"birds","fly"," come", "me", "can","sugar"," laugh","ss", "ad", "asad",
"digf","you ",
"know", "burn","ah ahh","desk","ic e", "look",
"hand","cry","b lood","goes","w ar",
"loop","open"," pass","throw"," age","monkey"," doom","hobaa"};
//*************** ****node class********** *********
class node{
private:
string word;
node *next;
public:
node()
{
next=NULL;
}
friend class list;
void display()
{
cout<<word<<" ";
}
};
//*************** **list class********** ***********
class list{
private:
node *head,*tail,*TO P;
void append(node *new_node);
public:
list()
{
TOP=new node;
head=tail=TOP;
TOP->next=NULL;
}
~list()
{
node *ptr=head;
while(ptr)
{
node *tmp=ptr;
ptr=ptr->next;
delete tmp;
}
head=tail=TOP=N ULL;
}
void getWords();
void displayAll();
};
void list::displayAl l()
{
node *py;
py=head;
if(py==NULL)
{
cout<<"nothing to show"<<endl;
}
while(py!=NULL)
{//while py points sth reasonable
py->display();
py=py->next;
}
}
void list::append(no de *ptr){
if(TOP->next==NULL)//first element
{ TOP->next=ptr;
head=ptr;
tail=ptr;
}
else
{
tail->next=ptr;
tail=ptr;
}
}
void list::getWords( )
{ int num;
srand((unsigned )time( NULL ));
for(int m=0;m<50;m++)
{
num=(rand()%53) ;
node *object;
object=new node;
object->word=words[num];
append(object);
}
}
void main()
{
list thelist;
thelist.getWord s();
thelist.display All();
}
Comment