daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct lista {
  6.     int val;
  7.     lista *next = 0;
  8. };
  9.  
  10. int main()
  11. {
  12.     int input;
  13.     lista *p, *q;
  14.     q = new lista;
  15.     p = q;
  16.     while (true) {
  17.         cout << "Inserisci valore: ";
  18.         cin >> input;
  19.         if (input==0) {
  20.             break;
  21.         }
  22.         p->val = input;
  23.         p->next = new lista;
  24.         p = p->next;
  25.     }
  26.     p = q;
  27.     while (p->next!=0) {
  28.         cout << p->val << endl;
  29.         p = p->next;
  30.     }
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top