刚刚编写完 呵呵 练习
#include<stdio.h>
#include<stdlib.h>
#define max 20
typedef int datetype;
typedef struct node
{
datetype date[max];
int length;
}sqlist;//定义顺序表
sqlist p1;
void reverlist()
{
int i;
for(i=0;i<p1.length/2;i++)
{
p1.date[p1.length+1]=p1.date[i];//把date[p1.length+1]作为中间存储单元
p1.date[i]=p1.date[p1.length-i-1];
p1.date[p1.length-i-1]=p1.date[p1.length+1];
}
}
int main()
{
int n,j;
p1.length=0;
printf("请输入n个数据:");
scanf("%d",&n);
for(j=0;j<n;j++)
{
scanf("%d",&p1.date[j]);
p1.length++;
}
printf("the sqlist is:/n");
for(j=0;j<n;j++)
printf("%d ",p1.date[j]);
printf("/n");
reverlist();
printf("the result is:/n");
for(j=0;j<n;j++)
printf("%d ",p1.date[j]);
printf("/n");
system("pause");
}
#include<stdlib.h>
#define max 20
typedef int datetype;
typedef struct node
{
datetype date[max];
int length;
}sqlist;//定义顺序表
sqlist p1;
void reverlist()
{
int i;
for(i=0;i<p1.length/2;i++)
{
p1.date[p1.length+1]=p1.date[i];//把date[p1.length+1]作为中间存储单元
p1.date[i]=p1.date[p1.length-i-1];
p1.date[p1.length-i-1]=p1.date[p1.length+1];
}
}
int main()
{
int n,j;
p1.length=0;
printf("请输入n个数据:");
scanf("%d",&n);
for(j=0;j<n;j++)
{
scanf("%d",&p1.date[j]);
p1.length++;
}
printf("the sqlist is:/n");
for(j=0;j<n;j++)
printf("%d ",p1.date[j]);
printf("/n");
reverlist();
printf("the result is:/n");
for(j=0;j<n;j++)
printf("%d ",p1.date[j]);
printf("/n");
system("pause");
}