概述
写在前面,当时练习以下程序是出于应试,以下有很多应试会考到的题目,例如,最小公倍数、日期转换、选择排序、逆序...如果有很多有应试需求的人们需要整理版的题库,我会抽时间去帮忙整理,祝大家考个好成绩。
//book.c 一本书的图书目录,本题来自C Primer Plus例题,当时觉得对于应用结构体帮助很大,照着敲了一遍。
#include<stdio.h>
#include<string.h>
char* s_gets(char*st,int n);
#define MAXTITL 41
#define MAXAUTL 31
struct book{
char title[MAXTITL];
char author[MAXAUTL];
float value;
};
int main()
{
struct book library;
printf("Please enter the book title.n");
s_gets(library.title,MAXTITL);
printf("Now enter the author.n");
s_gets(library.author,MAXAUTL);
printf("Now enter the value.n");
scanf("%f",&library.value);
printf("%s by %s: %.2fn",library.title,library.author,library.value);
printf("Done.n");
return 0;
}
char* s_gets(char*st,int n)
{
char* ret_val;
char* find;
ret_val=fgets(st,n,stdin);
if(ret_val)
{
find=strchr(st,'n');
if(find)
*find='