Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. struct list {
  4. float val;
  5. list* next;
  6. list* prev;
  7. };
  8.  
  9. int main()
  10. {
  11. int n;
  12. scanf_s("%d", &n);
  13.  
  14. list* head = new list;
  15. head->prev = NULL;
  16.  
  17. float c;
  18. scanf_s("%f", &c);
  19. head->val = c;
  20.  
  21. list* temp = head;
  22. for (int i = 2; i <= n; i++)
  23. {
  24. scanf_s("%f", &c);
  25. temp->next = new list;
  26. temp->next->val = c;
  27. temp->next->prev = temp->next;
  28. temp = temp->next;
  29. }
  30. temp->next = head;
  31. head->prev = temp;
  32.  
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement