Advertisement
Guest User

ASS1

a guest
Jan 18th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C Compiler.
  4. Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10. struct Node
  11. {
  12. int key;
  13. struct Node* next;
  14. struct Node* pre;
  15. };
  16.  
  17. struct List
  18. {
  19. struct Node* end;
  20. struct Node* current;
  21. struct Node* start;
  22. };
  23. struct Node arr2[100];
  24. struct Node* arr1[5];
  25. //for(int i=0; i<5;i++)
  26. //{
  27. // arr1[i]=NULL;
  28. //}
  29. struct List* ListCreate()
  30. {
  31.  
  32. int i;
  33. for (i=0; i<5;i++)
  34. {
  35. if(arr1[i]!=NULL)
  36. {
  37. continue;
  38. }
  39. else
  40. break;
  41. }
  42. if( i>= 5)
  43. return NULL;
  44. //printf("%d",i);
  45. struct List bbart;
  46. struct Node c;
  47. c.key=5;
  48. c.next=NULL;
  49. bbart.start=&c;
  50. struct List* d;
  51. arr1[i]=bbart.start;
  52. d=&bbart;
  53. return d;
  54. }
  55. int ListCount(struct List A)
  56. {
  57.  
  58. struct Node* temp=A.start;
  59. //printf("%d", A.start->key);
  60. int count=1;
  61. while(temp->next!=NULL)
  62. {
  63. count++;
  64. temp=temp->next;
  65.  
  66. }
  67. return count;
  68. }
  69. int main()
  70. {
  71. for(int i=0; i<5;i++)
  72. {
  73. arr1[i]=NULL;
  74. }
  75. //struct Node x;
  76. //arr1[0]=&x;
  77. struct List* A= ListCreate();
  78. struct Node e;
  79. e.key = 8;
  80. e.next = NULL;
  81. A->start->next = &e;
  82. //printf("%d", A->start->key);
  83. //ListCreate();
  84. //struct Node arr2[100];
  85. //struct Node* arr1[5];
  86. //ListCreate
  87. //printf("Hello World");
  88.  
  89. struct List C;
  90.  
  91. C.start->key=(*A).start->key;
  92. C.start->next=(*A).start->next;
  93.  
  94. int a=ListCount(C);
  95. struct List* B= ListCreate();
  96. printf("%d",a);
  97. //printf("%d", B->start->key);
  98. return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement