Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nodo{
- int inf;
- struct nodo *next;
- };
- void *crealista(struct nodo *testa1){
- struct nodo *p;
- testa1=NULL;
- char r;
- while(1) {
- p= new nodo;
- std::cout << "Inserisci valore" << '\n';
- std::cin >> p->inf;
- p->next=testa1;
- testa1=p;
- std::cout << "Vuoi aggiungere un altro elemento?" << '\n';
- std::cin >> r;
- if (r=='n'){
- break;
- }
- }
- }
- void *stampalista(struct nodo *testa1){
- struct nodo *p;
- p=testa1;
- char r;
- while(p->next!=NULL){
- std::cout << p->inf << '\n';
- p=p->next;
- }
- }
- int main() {
- struct nodo *testa;
- crealista(testa);
- stampalista(testa);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement