关于现行链表的简单应用!

废话不多说!!

#include<iostream>
using namespace std;

 

struct student{
 int num;
 struct student *next;
};
int main()
{
 struct student *p,*q;
 q=p=(struct student *)malloc(sizeof(struct student));
 int m=3;
 while(m--)
 {
 cin>>p->num;
 p->next=(struct student *)malloc(sizeof(struct student));
 if(m)
 p=p->next;
    else
 p->next=NULL;
 
 }
 
 while(q!=NULL)

 

 {
  cout<<q->num<<endl;
     q=q->next;
 }

 


 return 0;
}

 

相关文章:

  • 2022-12-23
  • 2021-05-18
  • 2022-01-20
  • 2021-10-29
  • 2021-11-28
  • 2021-06-04
  • 2022-12-23
猜你喜欢
  • 2021-08-20
  • 2021-06-30
  • 2022-02-24
  • 2022-12-23
  • 2022-03-10
  • 2021-10-13
  • 2021-12-09
相关资源
相似解决方案