逆序帮忙看一下

天地一棵树 2009-03-31 06:52:34
#include <stdio.h>
#include <conio.h>
#define MAXSIZE 100
typedef int ElemType;
typedef struct {
ElemType elem [MAXSIZE];
int size ;
} Sqlist;
void conerse_seq(SqList *l)
{ElemType i,n;
ElemType x;
n=L->size;
for (i=1;i<=n\2;i++;)
{x=L->elem[n-i+1];
L->elem[i]=L->elem[n-i+1];
L->elem[n-i+1]=x;
}
void Init_seq(sqlist *L)
{L->size=0;
void Greate_seq(sqlist *L)
{ElemType x;
int i=1;
printf("输入数据,以-999结束\n");
scanf("%d",&x);
while (x!=-999)
{L->elem[i++]=x;
scanf("%d",&x);
}
L->size=i-1;

void pf_seq(sqlist *L)
{int i;
for (i=1;i<=L->size ;i++)
printf("%4d",L->elem[i]);
}
void main()
{
get char();
sqlist *l=(sqlist*)malloc(sizeof(sqlist));
Init_seq(L);
Create_seq(L);
pf_seq(L);
converse_seq(L);

}
}
...全文
94 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
h13826013646 2009-03-31
  • 打赏
  • 举报
回复
#include <stdio.h>
#include<stdlib.h>
#include <conio.h>
#define MAXSIZE 100
typedef int ElemType;
typedef struct {
ElemType elem [MAXSIZE];
int size ;
} Sqlist;

void Init_seq(Sqlist *L)
{
L->size=0;
}
void Create_seq(Sqlist *L)
{
ElemType x;
int i=1;
printf("输入数据,以-999结束\n");
scanf("%d",&x);
while (x!=-999)
{
L->elem[i++]=x;
scanf("%d",&x);
}

L->size=i-1;
}

void pf_seq(Sqlist *L)
{
int i;
for (i=1;i<=L->size;i++)
printf("%4d",L->elem[i]);
printf("\n");
}

void converse_seq(Sqlist *L)
{
ElemType i,n;
ElemType x;
n=L->size;
for (i=1;i<=n/2;i++)
{
x=L->elem[i]; //这里搞错了
L->elem[i]=L->elem[n-i+1];
L->elem[n-i+1]=x;
}
}

void main()
{

Sqlist *L=(Sqlist*)malloc(sizeof(Sqlist));
Init_seq(L);
Create_seq(L);
converse_seq(L);
pf_seq(L);

}
Qlaiaqu 2009-03-31
  • 打赏
  • 举报
回复
语法改好了,有三个问题;
1.函数调用与函数定义名称不对,或大小写不对
2.函数间的间断错误
3.反转函数没有作用,这个你自己改吧
// exercise.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#define MAXSIZE 100

typedef int ElemType;

typedef struct {
ElemType elem [MAXSIZE];
int size ;
} Sqlist;

void converse_seq(Sqlist *L)
{
ElemType i,n;
ElemType x;
n=L->size;
for(i=1;i <=n/2;i++)
{
x=L->elem[n-i+1];
L->elem[i]=L->elem[n-i+1];
L->elem[n-i+1]=x;
}
}

void Init_seq(Sqlist *L)
{
L->size=0;
}

void Create_seq(Sqlist *L)
{
ElemType x;
int i=1;
printf("输入数据,以-999结束\n");
scanf("%d",&x);
while (x!=-999)
{
L->elem[i++]=x;
scanf("%d",&x);
}
L->size=i-1;
}

void pf_seq(Sqlist *L)
{
int i;
for (i=1;i <=L->size ;i++)
printf("%4d",L->elem[i]);
}

int main()
{
Sqlist *L=(Sqlist*)malloc(sizeof(Sqlist));
Init_seq(L);
Create_seq(L);
pf_seq(L);
converse_seq(L);
return 0;
}
kenstar 2009-03-31
  • 打赏
  • 举报
回复

#include <stdio.h>
#include <stdlib.h> //****** for malloc

#define MAXSIZE 100

typedef int ElemType;

typedef struct
{
ElemType elem [MAXSIZE];
int size ;
} Sqlist;

void converse_seq(Sqlist * L)//*******
{
int i,n; //****************************
ElemType x;
n=L->size;
for (i=0; i<n/2; i++) //******************这里好严重的错误
{
x=L->elem[i]; //*********
L->elem[i]=L->elem[n-1-i]; //********
L->elem[n-1-i]=x;
}
}//*********

void Init_seq(Sqlist *L)
{
L->size=0;
}//***********

void Create_seq(Sqlist *L) //*******
{
ElemType x;
int i=0; //**********
printf("输入数据,以-999结束\n");
scanf("%d",&x);
while (x!=-999)
{
L->elem[i++]=x;
scanf("%d",&x);
}
L->size=i; //********
}//********

void pf_seq(Sqlist *L)
{
int i;
for (i=0; i<L->size; i++)
printf("%4d",L->elem[i]);
}

void main()
{
Sqlist * L = (Sqlist*) malloc(sizeof(Sqlist)); //*********
Init_seq(L);
Create_seq(L);
pf_seq(L);
converse_seq(L);
pf_seq(L);//*********我加上的
free(L);//*********我加上的
}


楼主的编程风格要改一下呀,太乱了,还有太粗心了,不是漏"}"就是漏字母
希望楼主早日改正~~~
kenstar 2009-03-31
  • 打赏
  • 举报
回复

#include <stdio.h>
#include <stdlib.h> //****** for malloc

#define MAXSIZE 100

typedef int ElemType;

typedef struct
{
ElemType elem [MAXSIZE];
int size ;
} Sqlist;

void converse_seq(Sqlist * L)//*******
{
int i,n; //****************************
ElemType x;
n=L->size;
for (i=0; i<n/2; i++) //******************这里好严重的错误
{
x=L->elem[i]; //*********
L->elem[i]=L->elem[n-1-i]; //********
L->elem[n-1-i]=x;
}
}//*********

void Init_seq(Sqlist *L)
{
L->size=0;
}//***********

void Create_seq(Sqlist *L) //*******
{
ElemType x;
int i=0; //**********
printf("输入数据,以-999结束\n");
scanf("%d",&x);
while (x!=-999)
{
L->elem[i++]=x;
scanf("%d",&x);
}
L->size=i; //********
}//********

void pf_seq(Sqlist *L)
{
int i;
for (i=0; i<L->size; i++)
printf("%4d",L->elem[i]);
}

void main()
{
Sqlist * L = (Sqlist*) malloc(sizeof(Sqlist)); //*********
Init_seq(L);
Create_seq(L);
pf_seq(L);
converse_seq(L);
pf_seq(L);//*********我加上的
free(L);//*********我加上的
}


楼主的编程风格要改一下呀,太乱了,还有太粗心了,不是漏"}"就是漏字母
希望楼主早日改正~~~
konhon 2009-03-31
  • 打赏
  • 举报
回复
很多语法错误呀
帮你解决语法错误, 注意大小写.


#include <stdio.h>
#include <stdlib.h>

#define MAXSIZE 100

typedef int ElemType;

typedef struct {
ElemType elem [MAXSIZE];
int size ;
} Sqlist;

void conerse_seq(Sqlist *L)
{
ElemType i, n;
ElemType x;
n=L->size;
for(i=1;i<=n/2;i++)
{
x=L->elem[n-i+1];
L->elem[i]=L->elem[n-i+1];
L->elem[n-i+1]=x;
}
}

void Init_seq(Sqlist *L)
{
L->size=0;
}

void Greate_seq(Sqlist *L)
{
ElemType x;
int i=1;
printf("输入数据,以-999结束\n");
scanf("%d",&x);
while (x!=-999)
{L->elem[i++]=x;
scanf("%d",&x);
}
L->size=i-1;
}

void pf_seq(Sqlist *L)
{int i;
for (i=1;i <=L->size ;i++)
printf("%4d",L->elem[i]);
}

void main()
{
getchar();
Sqlist *L=(Sqlist*)malloc(sizeof(Sqlist));
Init_seq(L);
Greate_seq(L);
pf_seq(L);
conerse_seq(L);

}

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧