Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. void deleteAll(struct Elem* head) {
  2. struct Elem* cur_next = head;
  3. for (; head != NULL; head = cur_next) {
  4. cur_next = head->next;
  5. free(head->str);
  6. free(head);
  7. }
  8. }
  9.  
  10. void printList(struct Elem* head) {
  11. if (head == NULL) {
  12. return;
  13. }
  14. struct Elem* cur = head;
  15. while (cur != NULL) {
  16. printf("%s", cur->str);
  17. if (cur->next != NULL) {
  18. printf("%s", " ");
  19. }
  20. cur = cur->next;
  21. }
  22. }
  23.  
  24. int main() {
  25. int number;
  26. scanf("%d", &number);
  27. struct Elem* list = NULL;
  28. char line[1000];
  29. for (int i = 0; i < number; ++i) {
  30. scanf("%s", line);
  31. int k;
  32. scanf("%d", &k);
  33. list = process_3(list, line, k);
  34. list = process_3(list, NULL, k);
  35. }
  36. printList(list);
  37. deleteAll(list);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement