fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <malloc.h>
  4. struct LinkList
  5. {
  6. int data;
  7. struct LinkList *next;
  8. };
  9. struct LinkList Reverse ( LinkList *list )
  10. {
  11. LNode *tmp = NULL;
  12. LNode *p = NULL;
  13.  
  14. if (list == NULL)
  15. {
  16. return NULL;
  17. }
  18. tmp = list->next;
  19. while (tmp->next != NULL)
  20. {
  21. p = tmp->next;
  22. tmp->next = p->next;
  23. p->next = list->next;
  24. list->next = p;
  25. }
  26. return list;
  27. }
  28. int main( )
  29. {
  30. int i=0;
  31. int b;
  32. struct LinkList *L;
  33. struct LinkList *p;
  34. struct LinkList *q;
  35.  
  36. p=L->next;
  37. while (b!= -1)
  38. {
  39. while( scanf("%d\n",&b)&&(b>0) )
  40. { p->data=b;
  41. p=p->next;
  42. i++;
  43. }
  44. }
  45.  
  46. struct LinkList Reverse ( LinkList *L );
  47.  
  48. q=L->next;
  49. while(i>=0)
  50. {
  51. printf("%d\n",q->data);
  52. i--;
  53.  
  54. }
  55. return 0;
  56. }
  57.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'LinkList Reverse(LinkList*)':
prog.cpp:11:5: error: 'LNode' was not declared in this scope
     LNode   *tmp = NULL;
     ^
prog.cpp:11:14: error: 'tmp' was not declared in this scope
     LNode   *tmp = NULL;
              ^
prog.cpp:12:14: error: 'p' was not declared in this scope
     LNode   *p = NULL;
              ^
In file included from /usr/include/malloc.h:23:0,
                 from prog.cpp:3:
prog.cpp:16:16: error: could not convert '0' from 'int' to 'LinkList'
         return NULL;
                ^
prog.cpp:26:12: error: could not convert 'list' from 'LinkList*' to 'LinkList'
     return list;
            ^
stdout
Standard output is empty