diff --git a/LLtakinginput.cpp b/LLtakinginput.cpp new file mode 100644 index 0000000..814e3d9 --- /dev/null +++ b/LLtakinginput.cpp @@ -0,0 +1,51 @@ +#include +using namespace std; +class node +{ +public: + int data; + node *next; + + node(int d) + { + data=d; + next=NULL; + } +}; + +void insertathead(node*&head,int data) +{ + node*n=new node(data); + n->next=head; + head=n; +} + +void buildlist(node*&head) +{ + int data; + cin>>data; + while(data!=-1) + { + insertathead(head,data); + cin>>data; + } +} +void print(node*head) +{ + while(head!=NULL) + { + cout<data<<"->"; + head=head->next; + } +} + +int main() +{ + node*head=NULL; + buildlist(head); + print(head); + + return 0; + + +}