Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void deleteAll(struct Elem* head) {
- struct Elem* cur_next = head;
- for (; head != NULL; head = cur_next) {
- cur_next = head->next;
- free(head->str);
- free(head);
- }
- }
- void printList(struct Elem* head) {
- if (head == NULL) {
- return;
- }
- struct Elem* cur = head;
- while (cur != NULL) {
- printf("%s", cur->str);
- if (cur->next != NULL) {
- printf("%s", " ");
- }
- cur = cur->next;
- }
- }
- int main() {
- int number;
- scanf("%d", &number);
- struct Elem* list = NULL;
- char line[1000];
- for (int i = 0; i < number; ++i) {
- scanf("%s", line);
- int k;
- scanf("%d", &k);
- list = process_3(list, line, k);
- list = process_3(list, NULL, k);
- }
- printList(list);
- deleteAll(list);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement