当前位置: 代码迷 >> C语言 >> [求助]    一个C语言编程题-->yms123转移
  详细解决方案

[求助]    一个C语言编程题-->yms123转移

热度:286   发布时间:2007-06-30 11:53:27.0
回复:(mp3aaa)一般没人会帮你的 这个程序似乎要写很...

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct book
{
int flag;
int number;
char name[20];
char writer[20];
char print[20];
float prince;
}book[200]

void newlib(struct book[i],int n)
{
int i;
FILE*fp;
if((fp=fopen("record.tex","wb"))==NULL)
{ printf("can not open fire\n");
exit(1)
{
printf("\n saving file\n");
fprintf(fp,"%d",n);
fprintf(fp,"\r\n");
for(i=0;i<n;i++);
{ fprintf(fp,"%d",number;"%s",name;"%s",writer;"%s",print;"%d",price);
fprintf(fp,"\r\n");
}
fclose(fp);
printf("*********save success*********\n");
}

}
}

void appendbook()
{
int n;
page_title("append a new book");
for(n=0;n<200;n++)
if(book[n].id==0) break;
printf("number:");
scanf("%d",&book[n].number);
printf("name:");
scanf("%s",&book[n].name);
printf("writer:");
scanf("%s",&book[n].writer);
printf("print:");
scanf("%s",&book[n].print);
printf("price");
scanf("%d",&book[n].price);
return confirm();
}

void delbook()
{
int n;
page_title("delete this book");
if((n=searchbook())!==1)
book[n].id=0;
printf("this book is deleted");
return_confirm();
}

void searchbook()
{
int n,i;
printf("please inputb book'number:");
scanf("%d",&i);
for(n=0;n<200;n++)
{
if (book[n].id==i)
{
printf("number:%d\n",book[n].number);
printf("name:%s\n",book[n].name);
return n;
}
}
}

void sortby price()
{int i,j,t;
FILE *fp;
if(fp=fopen=("book.txt","rb")=NULL)
{printf("cannot open the file.\n");
exit(0);
}
for(i=0;i<N;j++)
for(j=i+1;j<N;j++)
if(book[i].price<book[j].price)
{
t=book.price[i];
book[i]=book[j];
book[j]=t;
}
}

void sortby num()
{
int i,j,t;
FILE *fp;
if(fp=fopen=("book.txt","rb")=NULL)
{printf("cannot open the file.\n");
exit(0);
}
for(i=0;i<N;j++)
for(j=i+1;j<N;j++)
if(book[i].num<book[j].num)
{
t=book.num[i];
book[i]=book[j];
book[j]=t;
}
}


----------------解决方案--------------------------------------------------------
回复:(mp3aaa)以下是引用killer_l在2007-6-25 21:0...

自立更生 艰苦创业
呵呵 我自己编的
不过 好象没法运行
各位 帮我看一下吧
好奇怪 就是运行不出来


----------------解决方案--------------------------------------------------------
  相关解决方案