Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <cstdlib>
  4. #include <stdio.h>
  5.  
  6. using namespace std;
  7.  
  8. struct node_s {
  9. int val;
  10. node_s *next;
  11.  
  12. };
  13.  
  14. void print(node_s* list) {
  15. node_s* temp = list;
  16. while (temp != NULL) {
  17. cout << temp->val;
  18. }
  19. }
  20.  
  21. int main() {
  22. int a;
  23. cin >> a;
  24. while(a != 0) {
  25. node_s *first = (node_s*)malloc(sizeof(struct node_s));
  26. node_s *last = first;
  27. first->next = NULL;
  28. first->val = a;
  29. last->next = (node_s*)malloc(sizeof(struct node_s));
  30. last = last->next;
  31. last->next = NULL;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement