Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2349157
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 17:59:49

#include"stdlib.h"
#include"stdio.h"
struct stud_type
{
   char name[20];
   long num;
   int age;
   char sex;

}student[30];
int n=0;
main()
{
char ch;
int flag=1;
while(flag)
{
printf("\ntype'E'or'e'to enter new record,");
printf("type'L'or'l'to all list record:");
ch=getchar();
getchar();
switch(ch)
{
case'e':
    case'E':new_record();break;
    case'l':
    case'L':listall();break;
default:flag=0;

}
}
}

new_record(void)
{
char numstr[20];
printf("\nrecord%d:\nenter name:",n+1);
gets(student[n].name);
printf("\nenter number:");
gets(numstr);
printf("\nenter age:");
gets(numstr);
printf("\nenter sex:");
student[n].sex=getchar();
getchar();
n++;

}

listall(void)
{
int i;
if (n<1)
printf("\nempty list. \n");
for(i=0;i{
printf("\nrecord number %d\n",i+1);
printf("name:%s\n,"student[i].name);
printf("num :%ld\n",student[i].num);
printf("age :%d\n",student[i].age);
printf("sex :%c\n",student[i].sex);
}
}

   您刚才发送的消息:“#include"stdlib.h"
#include"stdio.h"
struct stud_type
{
   char name[20];
   long num;
   int age;
   char sex;

}student[30];
int n=0;
main()
{
char ch;
int flag=1;
while(flag)
{
printf("\ntype'E'or'e'to enter new record,");
printf("type'L'or'l'to all list record:");
ch=getchar();
getchar();
switch(ch)
{
case'e':
    case'E':new_record();break;
    case'l':
    case'L':listall();break;
default:flag=0;

}
}
}

new_record(void)
{
char numstr[20];
printf("\nrecord%d:\nenter name:",n+1);
gets(student[n].name);
printf("\nenter number:");
gets(numstr);
printf("\nenter age:");
gets(numstr);
printf("\nenter sex:");
student[n].sex=getchar();
getchar();
n++;

}

listall(void)
{
int i;
if (n<1)
printf("\nempty list. \n");
for(i=0;i{
printf("\nrecord number %d\n",i+1);
printf("name:%s\n,"student[i].name);
printf("num :%ld\n",student[i].num);
printf("age :%d\n",student[i].age);
printf("sex :%c\n",student[i].sex);

--------------------next---------------------

阅读(1251) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~