Вы находитесь на странице: 1из 2

#include "stdafx.

h"
#include <iostream>
#pragma warning (disable:4996)
using namespace std;

struct Word
{
char *s;// ��� ������� strtoc �� string
Word *next;
};
void AddToList(char str[30], Word **head, Word *prew);
void Print(Word *word);
int main()
{

Word *curr= NULL;


Word *prew=new Word;
prew->next = new Word;
prew->next = curr;
AddToList("Hello", &curr,prew);
AddToList(" how are", &curr, prew);
AddToList(" you? ", &curr, prew);
AddToList(" you? ", &curr, prew);
AddToList(" you? ", &curr, prew);
Print(prew->next);
system("pause");

}
void AddToList(char str[30],Word **curr,Word *prew)
{
int counter = 0;
/*if (*curr == NULL)
{
*curr = new Word;
(*curr)->s = str;
(*curr)->next = NULL;
counter++;
}*/
//else {
int bird = 0;
Word *last = new Word;
last = prew;
while (last->next != NULL)
{
last = last->next;

bird++;
}
cout << "| " << bird << " |" << endl;
last->next = new Word;
last = last->next;
last->s = str;
last->next = NULL;
*curr = last;
counter += 2;

//}
cout << counter;
}
void Print(Word *word)
{
int i = 7;
Word *print = word;
while (print)
{
cout << print->s;
print = print->next;
}
}

Вам также может понравиться