#include "stdio.h"
#include "conio.h"
#define N 38
int i=0;
struct student
{
int num;
char name[13];
char sex[5];
char qq[12];
char phone[12];
char mail[30];
}
fun1(struct student fun1[N]) /* 1 input(addition) */
{
char choice;
do{ printf("num : \n");
fflush(stdin);
scanf("%d",&fun1[i].num);
printf("name[12] :\n");
fflush(stdin);
scanf("%s",fun1[i].name);
printf("sex[4] :\n");
fflush(stdin);
scanf("%s",fun1[i].sex);
printf("qq[11] :\n");
fflush(stdin);
scanf("%s",fun1[i].qq);
printf("phone[11] :\n");
fflush(stdin);
scanf("%s",fun1[i].phone);
printf(" mail[29] :\n");
fflush(stdin);
scanf("%s",fun1[i].mail);
i++;
printf(" continue to input ?(y/n) \n");
fflush(stdin);
scanf("%c",&choice);
}
while(choice=='y'||choice=='Y');
}
fun2(struct student fun2[N]) /* 2*delete */
{ int k,n,m;
int num;
char choice;
do{
printf("input the student number to delete:\n");
fflush(stdin);
scanf("%d",&num);
for(k=0;k<i;k++)
{ if(num==fun2[k].num)
{ for(num;num<i;num++)
{fun2[num-1]=fun2[num];}
}
}printf("After being delete the information is :\n");
printf("num name sex qq phone mail \n");
for(n=0;n<i-1;n++)
{printf("%-11d%-14s%-8s%-14s%-17s%-11s \n",fun2[n].num,fun2[n].name,fun2[n].sex,fun2[n].qq,fun2[n].phone,fun2[n].mail);}
i--;
printf("continue to delete the information ? (y/n)\n");
fflush(stdin);
scanf("%c",&choice);
}
while(choice=='y'||choice=='Y');
}
fun3(struct student fun3[N]) /* 3*amendment */
{ int k;
char choice;
int num;
do{ printf("input the student num to amend:\n");
fflush(stdin);
scanf("%d",&num);
for(k=0;k<i;k++)
{ if(num==fun3[k].num)
{printf("old informationg is:\n");
printf("num name sex qq phone mail \n");
printf("%-11d%-14s%-8s%-14s%-17s%-11s \n",fun3[k].num,fun3[k].name,fun3[k].sex,fun3[k].qq,fun3[k].phone,fun3[k].mail);
printf("input the new information :\n");
printf("num :\n");
fflush(stdin);
scanf("%d",&fun3[k].num);
printf("name :\n");
fflush(stdin);
scanf("%s",fun3[k].name);
printf("sex :\n");
fflush(stdin);
scanf("%s",fun3[k].sex);
printf("qq :\n");
fflush(stdin);
scanf("%s",fun3[k].qq);
printf("phone :\n");
fflush(stdin);
scanf("%s",fun3[k].phone);
printf("mail :\n");
fflush(stdin);
scanf("%s",fun3[k].mail);
}
}
printf("continue to amend the information ?(y|n)\n");
fflush(stdin);
scanf("%s",&choice);
}
while(choice=='y'||choice=='Y');}
fun4(struct student fun4[N]) /* 4*showing */
{ int k;
printf("..........................................the students informations............................................\n");
printf("num name sex qq phone mail \n");
for(k=0;k<i;k++)
{printf("%-9d%-14s%-8s%-14s%-17s%-11s \n",fun4[k].num,fun4[k].name,fun4[k].sex,fun4[k].qq,fun4[k].phone,fun4[k].mail);
}
}
fun5(struct student fun5[N]) /* 5*searching */
{int k;
char choice;
int num;
do{printf("input the num to searching:\n");
fflush(stdin);
scanf("%d",&num);
for(k=0;k<i;k++)
{if(num==fun5[k].num)
{ printf("num name sex qq phone mail \n");
printf("%-11d%-14s%-8s%-14s%-17s%-11s \n",fun5[k].num,fun5[k].name,fun5[k].sex,fun5[k].qq,fun5[k].phone,fun5[k].mail);
}
}
printf("continue to searching the students informations ?(y|n)\n");
fflush(stdin);
scanf("%s",&choice);
}
while(choice=='y'||choice=='Y');
}
void main()
{ struct student stu[N];
int num1;
char num;
printf("★★★★★★★★★★★★ welcome to here ★★★★★★★★★★★★★");
printf("\n editor:dong");
do
{printf("\n 1*input 2*delete 3*amendment 4*display 5*searching 6*addition:\n");
scanf("%d",&num1);
switch(num1)
{ case 1:fun1(stu);break;
case 2:fun2(stu);break;
case 3:fun3(stu);break;
case 4:fun4(stu);break;
case 5:fun5(stu);break;
case 6:fun1(stu);break;
default:printf("\n The number is out of range \n");
}
printf("\n continue to the main function ???(y/n):\n");
fflush(stdin);
scanf("%s",&num);
}
while(num=='y'||num=='Y');
printf("※※※※※※※※※※※Look forward to see you again !!!※※※※※※※※※※※※※");
getch();
}