|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
struct infor {
|
|
|
|
|
char num[50];
|
|
|
|
|
char name[50];
|
|
|
|
|
float price;
|
|
|
|
|
};
|
|
|
|
|
struct infor g;
|
|
|
|
|
FILE *part1;
|
|
|
|
|
void menu_s();
|
|
|
|
|
void input();
|
|
|
|
|
void check();
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
system("cls");//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
int n;
|
|
|
|
|
menu_s();
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
while(n)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
|
|
switch(n)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
input() ;break;
|
|
|
|
|
//case 2:
|
|
|
|
|
//output();break;
|
|
|
|
|
//case 3:
|
|
|
|
|
//updata();break;
|
|
|
|
|
case 4:
|
|
|
|
|
check();break;
|
|
|
|
|
//case 5:
|
|
|
|
|
//sales();break;
|
|
|
|
|
case 6:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
getch();
|
|
|
|
|
menu_s();
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void menu_s ()
|
|
|
|
|
{
|
|
|
|
|
printf("***********<2A><><EFBFBD>˵<EFBFBD>************\n");
|
|
|
|
|
printf("*********1:<3A><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>*********\n");
|
|
|
|
|
printf("*********2:<3A><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>*********\n");
|
|
|
|
|
printf("*********3:<3A><><EFBFBD>¿<EFBFBD><C2BF><EFBFBD>*********\n");
|
|
|
|
|
printf("*********4:<3A><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>*********\n");
|
|
|
|
|
printf("*********5:<3A><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>*********\n");
|
|
|
|
|
printf("*********6:<3A>˳<EFBFBD>ϵͳ*********\n");
|
|
|
|
|
printf("*********<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>*********\n");
|
|
|
|
|
printf("----------------------------\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void input()
|
|
|
|
|
{
|
|
|
|
|
char next='y';
|
|
|
|
|
part1=fopen("storg","rb+");
|
|
|
|
|
if(part1==NULL)
|
|
|
|
|
{
|
|
|
|
|
part1=fopen("storg","wb+");
|
|
|
|
|
if(part1==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//fseek(part1,0,SEEK_END);
|
|
|
|
|
while(next=='y')
|
|
|
|
|
{
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
gets(g.num );
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
gets(g.name );
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>۸<EFBFBD>\n");
|
|
|
|
|
scanf("%lf",&g.price );
|
|
|
|
|
fprintf(part1,"%10s%10s%10s",g.num ,g.name ,g.price );/*<2A><><EFBFBD>ļ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>루y/n<><6E>\n");
|
|
|
|
|
fflush(stdin);//<2F><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
next=getch();
|
|
|
|
|
}
|
|
|
|
|
fclose(part1);
|
|
|
|
|
}
|
|
|
|
|
void check()
|
|
|
|
|
{
|
|
|
|
|
part1=fopen("storg","rb+");
|
|
|
|
|
if(part1==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
rewind(part1);
|
|
|
|
|
printf("\n\n<EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>\n****************\n");
|
|
|
|
|
printf("id name price\n");
|
|
|
|
|
while(!feof(part1))
|
|
|
|
|
{
|
|
|
|
|
fscanf(part1, "%10s%10s%10s",g.num ,g.name ,&g.price);
|
|
|
|
|
//<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ṹ<EFBFBD><E1B9B9>
|
|
|
|
|
printf("%-10s %-10s %-10f\n",g.num ,g.name ,g.price);
|
|
|
|
|
}
|
|
|
|
|
fclose(part1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|