#include<stdio.h> #include<stdlib.h> void array_sequence()//顺序存储(数组)逆序的函数 { int len,i,j; scanf("%d",&len); int *arrary = new int [len]; for(i=0;i<len;i++) scanf("%d",&arrary[i]); j = len-1; for(i=0;i<len/2;j--,i++) { arrary[i] = arrary[i] + arrary[j]; arrary[j] = arrary[i] - arrary[j]; arrary[i] = arrary[i] - arrary[j]; } for(i=0;i<len;i++) printf("%d\t",arrary[i]); delete(arrary); } typedef struct stu{ int data; struct stu *next; }st; st *init_list() { st *head; head = (st *)malloc(sizeof(st)); head->next = NULL; return head; } st *create() { int n,x; st *head,*r,*s; head = init_list(); r = head; printf("请输入元素个数:"); scanf("%d",&n); while(n) { s = (st *)malloc(sizeof(st)); scanf("%d",&x); s->data = x; s->next = r->next; r->next = s; r = s; n--; } return head; } st *list_sequence(st *head)//链表逆序 { st *p,*q; p = head->next; head->next = NULL;//置为空表 while(p) { q = p; p = p->next; q->next = head->next;//类似于头插 head->next = q; } return head; } main() { st *head,*p; head = create(); head = list_sequence(head); p = head->next; while(p) { printf("%d ",p->data); p = p->next; } }
0.0分
1 人评分
回文串 (C语言代码)浏览:3095 |
Pascal三角 (C语言代码)浏览:1252 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:1482 |
1025题解浏览:796 |
1054题解浏览:516 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:742 |
输出九九乘法表 (C语言代码)浏览:1172 |
哥德巴赫曾猜测 (C语言代码)浏览:778 |
母牛的故事 (C语言代码)浏览:547 |
Manchester-A+B for Input-Output Practice浏览:1909 |