关键词不能为空

当前您在: 主页 > 英语 >

数据结构实验答案

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-01-25 09:30
tags:

-

2021年1月25日发(作者:usams)
#include
struct goods
{


char name[20];


char number[10];


int

price;

char addr[100];

};
void print_goods_mes(struct goods* pStu,int i)
{


printf(

message is:n

printf(
is:%snNumber
is:%snPrice
is:%dnAddress
is:%sn


}
void main()
{


struct goods goods[5]; for(int i=0;i<5;i++)


{



printf(



scanf(


}

for(i=0;i<5;i++)


{



print_goods_mes(&goods[i],i);



}

}



















#include
struct goods
{


char

name[20];


char

number[10];


float price;

char

addr[100];

};
void print_goods_mes(struct goods* pGoods,int i)
{


printf(

message is:n

printf(
is:%snNumber
is:%snPrice
is:%fnAddress
is:%sn


}
void main()
{


struct goods goods[5]; for(int i=0;i<5;i++)


{



printf(



scanf(


}

for(i=0;i<5;i++)


{



print_goods_mes(&goods[i],i);



}
}



#include
struct goods
{

long int number[10];

char




name[20];

float



price;

char




addr[100];
};
void print_goods_mes(struct goods* pgoods,int i)
{

printf(

printf(
is:%ldnname
is:%snprice
is:%fnaddress
is:%sn
}
void main()
{

struct goods goods[5]; for(int i=0;i<5;i++)


{



printf(



scanf(


}

for(i=0;i<5;i++)


{



print_goods_mes(&goods[i],i);



}

}








实验二

#include
























#include
typedef struct node


{

int data;


struct node *next;
}

List;int countNode(List *h)

{

List *p=h;


int i=1;

p=p->next;


while(p!=NULL)


{


printf(


i++;


p=p->next;


}


putchar('n');

return i-1;
}


main()
{

int a;

List *head,*p,*s;


p=head=(List *)malloc(sizeof(List));


while(1)

{



puts(


scanf(


getchar();



if(a!=-1)




{s=(List *)malloc(sizeof(List));


s->data=a;



s->next=NULL;


p->next=s;




p=p->next;
}




else break;

}

printf(
一共有

%d
个数值
n

}






实验三:

#include
#include
#define OK 1

#define ERROR 0

#define OVERFLOW -2

#define LISTINCREMENT 10

#define INFEASIBLE -1

#define STACK_INIT_SIZE 100

#define STACKINCREMENT 10

typedef int SElemType;

typedef int Status;

typedef int ElemType;

typedef struct SqStack

{


SElemType *base;


SElemType *top;


int stacksize;

}
SqStack;
Status InitStack(SqStack &S);

Status Push(SqStack &S,SElemType e);

Status Pop(SqStack &S,SElemType &e);

Status StackEmpty(SqStack S);

void convert(int a);

void main()

{


int n,M,e;

SqStack S;


InitStack(S);


printf(
请输入要转换的数字:



scanf(


M=n;

while(M)


{



Push(S,M % 2);



M = M / 2;


}


printf(
转换为二进制数为:



while(!StackEmpty(S))


{



Pop(S,e); printf(


}


printf(

}

Status InitStack(SqStack &S)

{



= (SElemType *)malloc(STACK_INIT_SIZE * sizeof(SElemType));


if(!) exit(OVERFLOW);



=



ize=STACK_INIT_SIZE;



return OK;


}


Status Pop(SqStack &S,SElemType &e)

{



if( == ) return ERROR;


e = *--;


return OK;


}

Status Push(SqStack &S,SElemType e)

{

if( - >= ize)


{




=
(ElemType
*)realloc(,(ize
+
LISTINCREMENT)
*
sizeof(ElemType));



if(!) exit(OVERFLOW);



= + ize;



ize += STACKINCREMENT;


}


*++ = e; return OK;


}

Status StackEmpty(SqStack S)
{

if( == ) return OK;

else return ERROR;

}

void convert(int e)

{


if(e==0) printf(


if(e==1) printf(

}




















-


-


-


-


-


-


-


-



本文更新与2021-01-25 09:30,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/565128.html

数据结构实验答案的相关文章

  • 爱心与尊严的高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊严高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊重的作文题库

    1.作文关爱与尊重议论文 如果说没有爱就没有教育的话,那么离开了尊重同样也谈不上教育。 因为每一位孩子都渴望得到他人的尊重,尤其是教师的尊重。可是在现实生活中,不时会有

    小学作文
  • 爱心责任100字作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任心的作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文