Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct List
- {
- int inf;
- List* link;
- }*head;
- void Create(List*& head)
- {
- head = NULL;
- }
- void Input(int x, List*& list)
- {
- List* q = new List;
- q->inf = x;
- q->link = list;
- list = q;
- }
- void Print(List*& list)
- {
- while (head != NULL)
- {
- cout << head->inf << endl;
- head = head->link;
- }
- }
- int main()
- {
- int n, x;
- List* list;
- Create(head);
- cout << "Enter the count of numbers: ";
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cin >> x;
- if (i == 0)
- {
- head->inf = x;
- head->link = NULL;
- }
- Input(x, list);
- }
- cout << head->inf;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement