Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by Górka ( 13 years ago )
#include "stdafx.h"
#include <iostream>
using namespace std;
struct element {
int key;
element* next;
};
void dodaj (element* &tail;, int x)
{
element* t;
t= new element;
t->key=x;
t->next=NULL;
tail->next=t;
tail=t;
}
void wyswietl (element* &head;)
{ element* z;
z=head;
while (z!=NULL)
{ int x;
x=z->key;
cout<<x<<endl;
z=z->next;}
}
void odwroc (element* &head;)
{
element* t;
element* n;
t=head;
while(t->next!=0)
{n=t->next;
t->next=n->next;
n->next=head;
head=n;
}
}
int main(int argc, char* argv[])
{
element* lista= new element;
element* head= lista;
element* tail= lista;
int x,y;
cout<<"Podaj x"<<endl;
cin>>x;
lista->key=x;
lista->next=NULL;
for (int i=0; i<5; i++)
{cout<<"Podaj x"<<endl;
cin>>x;
dodaj(tail, x);}
odwroc(head);
wyswietl(head);
system ("pause");
}
Revise this Paste