int main(){
int i,t,n,a[10]
scanf("%d",&n)
for(i=0i<ni++)
scanf("仿核%d",&a[i])
for(i=0i<n/2i++)
{t=a[i]a[i]=a[n-i-1]a[n-i-1]=t}
for(i=0i<纳大唯ni++)
printf("%d ",a[i])
return 0
}
//运行示例:
楼主你好!关于你的问题,我已经将代迟敏卖码实现如下,如有错误,请指正!谢谢!
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct list{
int data
struct list *next
}
struct list*CreateList(int n){ //用于创建链表
struct list *head=NULL,*p,*q
int i
for(i=1i<=ni++){
p=(struct list*)malloc(sizeof(struct list))
printf("Please input the number:")
scanf("拿辩%d",&p->data)
if(head==NULL){head=p}
else{q->next=p}
q=p
}
p->next=NULL
return head
}
void Output(struct list *head){ //用于将链表每个节点显示出来
while(head!='\0'){
printf("%d\n",head->data)
head=head->next
}
}
struct list *Inverse(struct list *head){ //用于链表的逆转
struct list *p=NULL,*q
while(head!=NULL){
q=p
p=head
head=head->next
p->next=q
}
head=p
return head
}
main(){
struct list *head
head=CreateList(5)
head=Inverse(head)
Output(head)
getch()
}
希望我的回答对码逗你有帮助!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)