//linked list inserting a node in the begginging;
#include <iostream>
using namespace std;
struct node
{
char esm[30];
node* next;
};
void print(node* head)
{
for (; head; head = head->next)
{
cout << head->esm << endl;
}
}
node* ezafekardan_niro(node* head)
{
node* niro = new node;
niro->next = NULL;
cout << "esm"<<endl;
cin >> niro->esm;
niro->next = head;
head = niro;
retu head;
}
node *hazf_niro(node *head)
int main()
{
node* head = NULL;
unsigned short tedad_karkonan = 0;
cin >> tedad_karkonan;
cout << endl;
for (unsigned short i = 0; i < tedad_karkonan; i++)
{
head = ezafekardan_niro(head);
cout << endl;
}
cout << "LIST afrad: " << endl;
cout << endl;
print(head);
retu 0;
}
+ نوشته شده در دوشنبه 13 بهمن 1399 ساعت: 20:50 توسط محمد رضا جوادیان
برچسب ها:
|