标签:next cst put ret eof return sha int list
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
struct List
{
int date;
List *next;
};
void creat(List *head) //往头指针后加,倒序
{
List *p;
head->next=NULL;
int a[100];
int i,j,k;
int n;
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
p=(List*)malloc(sizeof(List));
p->date=a[i];
p->next=head->next;
head->next=p;
}
return ;
}
void creat1(List *head) //正序
{
int n,i,j,k;
int a[100];
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
List *p,*q;
q=(List*)malloc(sizeof(List));
head->next=q;
q->next=NULL;
for(i=0;i<n;i++)
{
p=(List*)malloc(sizeof(List));
q->date=a[i];
p->next=NULL;
q->next=p;
q=p;
}
return;
}
void charu(List *head,int n)
{
List *p=head->next;
int i=1;
while(i!=n)
{
p=p->next;
i++;
}
int num;
cin>>num;
List *q;
q=(List*)malloc(sizeof(List));
q->date=num;
q->next=p->next;
p->next=q;
}
void shanchu(List *head,int n)
{
List *p=head->next;
int i=2;
while(i!=n)
{
p=p->next;
i++;
}
p->next=p->next->next;
}
void put(List *head)
{
List *p;
p=head->next;
while(p->next!=NULL)
{
cout<<p->date<<endl;
p=p->next;
}
return ;
}
int main()
{
List head;
creat1(&head);
// int n;cin>>n;
// charu(&head,n);
int u;cin>>u;
shanchu(&head,u);
put(&head);
return 0;
}
标签:next cst put ret eof return sha int list
原文地址:https://www.cnblogs.com/jk17211764/p/9695524.html