Untitled

 avatar
unknown
plain_text
6 days ago
898 B
3
Indexable
// d.cpp : This file contains the 'main' function. Program execution begins and ends there.
//



#include <iostream>
#include <vector>
#include <list>
using namespace std;
struct List {
    string id;
    int data;
    List* next = nullptr;
};
void f(List** x);
void scriere(List* a);

int main()
{
    List* head = new List();
   //ead->data = 10;
    f(&head);
    //scriere(head);
    //cout << head->next->data;
    f(&head);
  //  cout << head->next->next->data;
     scriere(head);
}

void scriere(List* a)
{
    List* s;
    s = a;
    while (s != nullptr)
    {

        cout << s->data << " ";
        s = s->next;

    }
}

void f(List** x)
{
    List* element1 = new List();
    cin >> element1->data;

    List* temp = *x;
    while (temp->next != nullptr)
    {
        temp = temp->next;

    }
    temp->next = element1;
}


Editor is loading...
Leave a Comment