J
jw
//it sometimes crashes sometimes not why?
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<ctime>
using namespace std;
#ifndef NULL
#define NULL (short) 0
#endif
char
*words[53]={"come","garden","one","nice","go","we","some","where","old",
"days","who","bilir","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","ice", "look",
"hand","cry","blood","goes","war",
"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,*TOP;
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=NULL;
}
void getWords();
void displayAll();
};
void list::displayAll()
{
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(node *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.getWords();
thelist.displayAll();
}
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<ctime>
using namespace std;
#ifndef NULL
#define NULL (short) 0
#endif
char
*words[53]={"come","garden","one","nice","go","we","some","where","old",
"days","who","bilir","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","ice", "look",
"hand","cry","blood","goes","war",
"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,*TOP;
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=NULL;
}
void getWords();
void displayAll();
};
void list::displayAll()
{
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(node *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.getWords();
thelist.displayAll();
}