Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  testnina
Language: C/C++
Code:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>

struct list_el {
   int val;
   struct list_el * next;
};

typedef struct list_el item;

int main(int argc, char *argv[])
{
     item * curr, * head,* p, * q, * r;
   int i;

   head = NULL;

   for(i=1;i<=10;i++) {
      curr = (item *)malloc(sizeof(item));
      curr->val = i;
      curr->next  = head;
      head = curr;
   }

   curr = head;
   
     p=head;
     q=p->next;
     p->next=NULL;

     while (q)
     {
          r = q->next;
          q->next = p;
          p = q;
          q = r;
     }


   while(p) {
      printf("%d\t", p->val);
      p = p->next ;
   }
return (int)getch();
}
          
          
          
          
          
          
          
          
Comments: