bdhhdhdh& 2022-10-03 18:21 采纳率: 82.4%
浏览 32
已结题

为什么后几个函数输出没有结果


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXSIZE 20
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
typedef  int ELemtype;
typedef int Status;
typedef struct ListNode
{
    ELemtype  data[MAXSIZE];
    int length;

}*Sqlist;
Sqlist Initlist()
{
    Sqlist L;
    L = (Sqlist)malloc(sizeof(struct ListNode));
    L->length= 0;
    return L;
}
Status Output(Sqlist L)
{
    int i;
    for (i = 0; i < L->length; i++)
    {
        printf("%d\n", L->data[i]);
    }
    printf("\n");
    return OK;
}
Status GetELem(Sqlist L, int i,ELemtype *e)
{
    if ((L->length = 0) || i<1 || i>L->length)
    {
        return ERROR;
    }
    *e = L->data[i-1];
    return OK;
}
Status ListInsert(Sqlist L,int i,ELemtype e)
{
    int k;
    if (L->length == MAXSIZE)
        return ERROR;
    if (i<1 || i>L->length + 1)
        return ERROR;
    if (i <= L->length)
    {
        for (k = L->length-1;k>=i-1;k--)
        {
            L->data[k + 1] = L->data[k];
        }
    }
    L->data[i - 1] = e;
    L->length++; 
        return OK;
}
Status ListDelet(Sqlist L, int i,ELemtype *e)
{
    int k;
    if (L->length = 0)
        return ERROR;
    if (i > L->length || i < 1)
        return ERROR;
    *e = L->data[i];
    if (i < L->length)
    {
        for (k = i; k < L->length; k++)
        {
            L->data[k - 1] = L->data[k];
        }
    }
    L->length--;
    return OK;
}
int main()
{
    Sqlist L;
    L =Initlist();
    int n, i, x;
    printf("please input the number of the line\n");
    scanf("%d", &n);
    printf("please input every number\n");
    for (i = 1; i <= n; i++)
    {
        scanf("%d", &x);
        ListInsert(L, i, x);
    }
    printf("the result of line:\n");
    Output(L);
    int e, j;
    printf("input a number of the number\n");
    scanf("%d", &j);
    GetELem(L, j, &e);
    printf("the %d number is %d\n", j, e);
    int k, e1;
    printf("请输入要删除的元素序号\n");
    scanf("%d", &k);
    ListDelet(L, k, &e1);
    printf("删除后的结果为:\n");
    Output(L);
    printf("the %d is leave\n", e1);



}

img

为什么e的值是乱码?
为什么进行删除操作后没有打印结果?

  • 写回答

2条回答 默认 最新

  • 浪客 2022-10-03 18:49
    关注

    37,65行里=改为==

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月12日
  • 已采纳回答 10月4日
  • 创建了问题 10月3日

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路