سلام
می خوام یه برنامه بنویسم که یک لیست رو کلا تو یه لیست دیگه برعکس کپی کنه لیست دومی رو چاپ کنه .
این برنامه رو نوشتم منتها جواب نمیده
#include<iostream.h>
struct Node
{
int info;
Node *next;
}*first , *tmp , *start;
void nodes ()
{
tmp = new Node;
first = tmp;
int x;
do
{
cin >> x;
tmp->info = x;
tmp->next = new Node;
tmp = tmp->next ;
}while(x > 0);
tmp->next = NULL;
}
void fanction()
{
tmp = first;
Node *help = new Node;
start = help;
help->next = NULL;
start = help;
while (tmp->next != NULL)
{
help->info = tmp->info;
start = help;
help->next = new Node;
tmp = tmp->next;
}
}
void print ()
{
tmp = start;
cout << "Answer :: \n";
while (tmp->next)
{
cout << tmp->info << endl;
tmp = tmp->next;
}
}
int main ()
{
nodes();
fanction();
print();
}