33,311
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include <stdlib.h>
#define NULL (void *)0
typedef struct{
int A;
}sqlist;
typedef int status;
void inistlist(sqlist **a,status n)
{
status i;
*a = (sqlist*)malloc(n * sizeof(sqlist));
if (!(*a))
return;
for(i = 0;i<n;i++)
scanf("%d", &(*a)[i].A);
}
status Max(sqlist *a,status n)
{
status max,i;
max = a[0].A;
for(i = 1; i < n; i++)
if(max < a[i].A)
max = a[i].A;
return max;
}
void destroylist(sqlist *a)
{
free(a);
a = NULL;
}
int main()
{
sqlist *m=NULL;
status n;
printf("Please input the n:");
scanf("%d",&n);
inistlist(&m, n);
printf("max = %d\n",Max(m,n));
destroylist(m);
return 0;
}
scanf("%d", &(*a)[i].A);
#include<stdio.h>
#include<stdlib.h>
#define NULL 0
typedef struct
{
int A;
} sqlist;
typedef int status;
sqlist * inistlist(status n)
{
status i;
sqlist *a=(sqlist*)malloc(n*sizeof(sqlist));
for(i=0; i<n; i++)
scanf("%d",&a[i]);
return a;
}
status Max(sqlist *a,status n)
{
status max,i;
max=a[0].A;
for(i=1; i<n; i++)
if(max<a[i].A) max=a[i].A;
return max;
}
void destroylist(sqlist *a)
{
free(a);
a=NULL;
}
int main()
{
sqlist *m=NULL;
status n;
printf("Please input the n:");
scanf("%d",&n);
m = inistlist(n);
printf("max=%d\n",Max(m,n));
destroylist(m);
return 0;
}