-
#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)
下一篇:英文图纸技术要求翻译