首页 > > 详细

辅导留学生asp编程、Java程序辅导、讲解Java、C/C++讲解、辅导php编程

# include
# include
# include
# include
# define NUM 50
# define field_num 7
typedef struct bookinfo
{
int idnumber; /**/
char bookname[20]; /**/
char writer[10]; /**/
char clanum[6]; /**/
char press[20]; /**/
char pubtime[12]; /**/
float price; /**/
}BookInfo;
/******************************************/
int menu_select();
int input(BookInfo book[]);/**/
void sort(BookInfo b[],int length);/**/
int insert(BookInfo b[],int length);/**/
int delet(BookInfo b[],int length);/**/
void lookup(BookInfo *b, int length);/**/
void modify(BookInfo *b,int length);/**/
int load(BookInfo *b);/**/
void save(BookInfo *b,int length);/**/
int Check_idnumber(int);/*,*/
void print_space (int n); /**/
void display(BookInfo b[],int length);
/*************************************************/
int main()
{
int i;
BookInfo book[NUM];
int length; //
system("CLS");
for (;;)
{
switch(menu_select())
{
case 0: length=input(book); break;
case 1: sort(book,length); break;
case 2: length=insert(book,length); break;
case 3: length=delet(book,length); break;
case 4: modify(book,length); break;
case 5: lookup(book,length); break;
case 6: length=load(book); break;
case 7: save(book,length); break;
case 8: display(book,length);break;
case 9: exit(0);
}
}
}
int menu_select()
{
char s[80];
int c;
// gotoxy(1,25);
printf("press any key enter menu......\n");
// getch();
system("CLS");
// gotoxy(1,1);
printf(" **************************************\n");
printf(" * ** 0. *\n");
printf(" * ***1. *\n");
printf(" * ****2. *\n");
printf(" * *****3. *\n");
printf(" * ******4. *\n");
printf(" * ******5. *\n");
printf(" * *****6. *\n");
printf(" * ****7. *\n");
printf(" * ***8. *\n");
printf(" * **9. *\n");
printf(" **************************************\n");
do {
printf("\nEnter you choice(0~8):");
scanf("%s",s);
c=atoi(s);
} while (c9);
return c;
}
void print_space (int n)
{
int i;
for (i=0;i=field_name_size[i])
field_length[i]=strlen(table_head[i]);
else
field_length[i]=field_name_size[i];
}
for (i=0;ilength) printf (",:\n");
} while (numberlength);
do
{
printf("\n:");
fflush(stdin);
scanf("%d",temp.idnumber);
} while(Check_idnumber(b,temp.idnumber,length)); //
for (i=length;i>=number;i--)
b[i]=b[i-1];

b[i].idnumber=temp.idnumber;
printf(":");
fflush(stdin);
gets(b[i].bookname);
printf(":");
gets(b[i].writer);
printf(":");
scanf("%s",b[i].clanum);
printf(":");
gets(b[i].press);
printf(":");
scanf("%s",b[i].pubtime);
printf(":");
scanf("%f",b[i].price);
length++;
return length;
}

int find(BookInfo b[],int length,int inum) //
{
int i;
for (i=0;ilength-1) printf("");
else
{
// printf(b[i]);
printf("?(Y/N)");
scanf("%c",ch);
if (ch=='y'||ch=='Y')
{
for (j=i+1;j=length)
printf("。");
}
int load(BookInfo *b)
{
FILE *fp;
int i,number;
char infile[10];
printf(":");
fflush(stdin);
scanf("%s",infile);
if((fp=fopen(infile,"rb"))==NULL){
printf("%s!\n",infile);
return -1;
}
number=0;
for(i=0;i if(fread(b[i],1,sizeof(BookInfo),fp)<=0)
break;
number++;
}
fclose(fp);
printf("%s!\n",infile);
return number;
}
void save(BookInfo *b,int length)
{
FILE *fp;
char outfile[10];
int i;
printf(":");
fflush(stdin);
scanf("%s",outfile);
if((fp=fopen(outfile,"wb"))==NULL)
{
printf("\n!");
return;
}
for(i=0;i fwrite(b[i],1,sizeof(BookInfo),fp);
fclose(fp);
printf("!!!");
}
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!