Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1.  
  2. node_t* temp = (node_t*)malloc(sizeof(node_t));
  3. if(temp==NULL){
  4. return NULL;
  5. }
  6. temp->value=value;
  7. temp->next = NULL;
  8. return temp;
  9.  
  10.  
  11. if(list==NULL){
  12. return 1;
  13. }
  14. node_t* temp = init_node(value);
  15. if(temp == NULL){
  16. return 1;
  17. }
  18. temp->next = list->first;
  19. list->first=temp;
  20. list->size++;
  21. return 0;
  22.  
  23.  
  24.  
  25. //////////////////
  26.  
  27. //
  28. // Created by guillaume on 17.02.20.
  29. //
  30.  
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <stdio.h>
  34.  
  35. int main(int argc, char* args[]){
  36. int int1 = atoi(args[1]);
  37. int int2 = atoi(args[3]);
  38. char* string = args[2];
  39. if(strcmp(args[2],"-eq")==0){
  40. return !(int1 == int2);
  41. }
  42. else if(strcmp(args[2],"-ge")==0){
  43. return !(int1>=int2);
  44. }
  45. else if(strcmp(args[2],"-gt")==0){
  46. return !(int1>int2);
  47. }
  48. else if(strcmp(args[2],"-le")==0){
  49. return !(int1<=int2);
  50. }
  51. else if(strcmp(args[2],"-lt")==0){
  52. return !(int1<int2);
  53. }
  54. else if(strcmp(args[2],"-ne")==0){
  55. return !(int1!=int2);
  56. }
  57. else{
  58. return -1;
  59. }
  60. }
  61.  
  62.  
  63. /////////////////
  64.  
  65. #include <string.h>
  66. #include <stdlib.h>
  67.  
  68.  
  69.  
  70.  
  71. if(head==NULL){
  72. return NULL;
  73. }
  74. if(head->next != NULL && head->next->next==NULL){
  75. struct node* first = malloc(sizeof(struct node));
  76. memcpy(first,head, sizeof(struct node));
  77. first->next=NULL;
  78. return first;
  79. }
  80. struct node* current = head->next;
  81. int index = 1;
  82.  
  83. struct node* tempPointer = (struct node*) malloc(sizeof(struct node));
  84. struct node* tempax = tempPointer;
  85. if(tempPointer==NULL){
  86. return NULL;
  87. }
  88.  
  89. memcpy(tempPointer,head, sizeof(struct node));
  90.  
  91. while(current != NULL){
  92. if(index%2 ==0){
  93. tempPointer->next=malloc(sizeof(struct node));
  94. memcpy(tempPointer->next, current, sizeof(struct node));
  95. tempPointer=tempPointer->next;
  96. }
  97. current = current->next;
  98. index ++;
  99. }
  100. return tempax;
  101.  
  102.  
  103.  
  104.  
  105. /////////////////////////
  106.  
  107. node_t *node = malloc(sizeof(node_t));
  108. if(node==NULL){
  109. return -1;
  110. }
  111. node->value = val;
  112. if (q->size == 0) {
  113. node->next=node;
  114. q->tail=node;
  115. q->size=1;
  116. return 0;
  117. }
  118. else{
  119. node->next=q->tail->next;
  120. q->tail->next=node;
  121. q->size++;
  122. return 0;
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129. int val=q->tail->value;
  130. if(q->size==1){
  131. free(q->tail);
  132. q->tail=NULL;
  133. q->size=0;
  134. return val;
  135. }
  136. node_t* node = q->tail;
  137. while(node->next!=q->tail){
  138. node = node->next;
  139. }
  140. node->next=q->tail->next;
  141. free(q->tail);
  142. q->tail=node;
  143. q->size--;
  144. return val;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement