/*合同管理系统*/
/******头文件(.h)***********/
#include
#include
#include
#include "ctype.h"
#define M 50
struct addressbook
{
int num;
char name[20];
float money[20];
char jia[15];
char yi[15];
int creatline[15];
int deadline[15];
char carryout[15];
char classify[15];
};
typedef struct addressbook AddressBook;
int Init(AddressBook t[]);
int AddRecord(AddressBook t[],int n);
void List(AddressBook t[],int n);
void SearchOnName(AddressBook t[],int n); void changeOnName(AddressBook t[],int n); int Deleteonname(AddressBook t[],int n); void SortOnNum(AddressBook t[],int n);
int quantityonjia(AddressBook t[]);
void SaveRecord(AddressBook t[],int n);
int LoadRecord(AddressBook t[]);
int Menu_select();
void main()
{
AddressBook adr[M];
int length;
while(1)
{
switch(Menu_select())
{
case 1: length=Init(adr);
SaveRecord(adr,length);
break;
case 2:length=LoadRecord(adr);
AddRecord(adr,length);
break;
case 3:length=LoadRecord(adr);
List(adr,length);
break;
case 4:length=LoadRecord(adr);
SearchOnName(adr,length);
break;
case 5:length=LoadRecord(adr);
changeOnName(adr,length);
SaveRecord(adr,length);
List(adr,length);
break;
case 6:length=LoadRecord(adr);
Deleteonname(adr,length);
SaveRecord(adr,length);
List(adr,length);
break;
case 7:length=LoadRecord(adr);
SortOnNum(adr,length);
SaveRecord(adr,length);
List(adr,length);
break;
case 8:length=LoadRecord(adr);
quantityonjia(adr,length);
break;
case 0:exit(0); /*如返回值为0则程序结束*/
}
}
}
int Menu_select()
{
int c;
printf("press any key enter menu......\n");
getchar(); /*读入任意字符*/
printf("********************************MENU*********************************\n\ 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(" 0. 退出\n");
printf("*********************************************************************\n"); do{
printf("\n Enter your choice(0-8):");
if(scanf("%d",&c)!=1)
{ while(getchar()!='\n')
continue;
/* continue;*/
}
}while(c<0||c>8);
return c;
}
int Init(AddressBook t[])
{
int i,n;
system("cls");
printf("\n请输入要输入的记录数:\n");
scanf("%d",&n);
printf("开始输入记录:\n");
for(i=0;i { system("cls"); printf("\n第%d条合同的编号:",i+1); scanf("%d",&t[i].num); printf("第%d条合同的名称:",i+1); scanf("%s",t[i].name); printf("第%d条合同的金额:",i+1); scanf("%s",t[i].money); printf("第%d条合同的甲方:",i+1); scanf("%s",t[i].jia); printf("第%d条合同的乙方:",i+1); scanf("%s",t[i].yi); printf("第%d条合同的等级:",i+1); scanf("%s",t[i].classify); printf("第%d条合同的生效日期:",i+1); scanf("%s",t[i].creatline); printf("第%d条合同的到期日期:",i+1);