</blockquote></div><div class="blockcode"><blockquote>#include <stdio.h>
#include <malloc.h>
#define P printf
#define S scanf
struct stu
{
char name[20];
char set[5];
char phone[15];
};
int main()
{
struct stu *p;
int num(void);
void fuzhi( struct stu *q, int n); //输入数据
void shuchu( struct stu *q1, int n1); //输出数据
int len;
len = num();
p = (int *)malloc(sizeof(int)*len);
fuzhi( p, len );
shuchu( p, len );
getch();
return 0;
}
int num(void)
{
int i;
while(1)
{
P("How much you want to store a number: \n");
S("%d",&i);
if( i >= 1 )
{
return i;
}
}
}
void fuzhi( struct stu *q, int n)
{
int i;
for ( i = 0; i < n; i++ )
{
P("第%d位:\n",i+1);
P("Please input your name:\n");
S("%s",&q[i].name);
P("Please input your set:\n");
S("%s",&q[i].set);
P("Please input your phone:\n");
S("%s",&q[i].phone);
}
}
void shuchu( struct stu *q1, int n1)
{
int i;
P("Name: Set: Phone:\n");
for( i = 0; i < n1; i++ )
{
P("%d: ",i+1);
P("%s %s %s \n",q1[i].name,q1[i].set,q1[i].phone);
}
}