Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <cstdlib>
- #include <stdio.h>
- using namespace std;
- struct node_s {
- int val;
- node_s *next;
- };
- void print(node_s* list) {
- node_s* temp = list;
- while (temp != NULL) {
- cout << temp->val;
- }
- }
- int main() {
- int a;
- cin >> a;
- while(a != 0) {
- node_s *first = (node_s*)malloc(sizeof(struct node_s));
- node_s *last = first;
- first->next = NULL;
- first->val = a;
- last->next = (node_s*)malloc(sizeof(struct node_s));
- last = last->next;
- last->next = NULL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement