添加指定图书

来源:互联网 发布:时时彩系统彩源码 编辑:程序博客网 时间:2024/05/16 01:13

#include<stdio.h>
#include<string.h>
struct time
{
 int year;
 int mouth;
 int day;
};
struct book
{
 int a;
 char shuming[30];
 char zuozhe[30];
 char chubanshe[30];
 struct time time;
 double z;
};
main()
{
 struct book c[20];
 int n, i, k;
 scanf("%d", &n);
 for(i=0;i<n;i++)
 scanf("%d %s %s %s %d-%d-%d %lf", &c[i].a, c[i].shuming, c[i].zuozhe, c[i].chubanshe, &c[i].time.year, &c[i].time.mouth, &c[i].time.day, &c[i].z);
 scanf("%d", &k);
 for(i=n;i>k-1;i--)
 {  
  c[i]=c[i-1];
 }
 scanf("%d %s %s %s %d-%d-%d %lf", &c[k-1].a, c[k-1].shuming, c[k-1].zuozhe, c[k-1].chubanshe, &c[k-1].time.year, &c[k-1].time.mouth, &c[k-1].time.day, &c[k-1].z);
 printf("编号 书名 作者 出版社 出版日期 价格\n");
 for(i=0;i<n+1;i++)
 printf("%d %s %s %s %d年%d月%d日 %.2lf\n", c[i].a, c[i].shuming, c[i].zuozhe, c[i].chubanshe,c[i].time.year, c[i].time.mouth, c[i].time.day, c[i].z);
}
原创粉丝点击