From 0eeab3893d96478502e16058c5e5fec4335ca706 Mon Sep 17 00:00:00 2001 From: 18783852161 <18783852161@163.com> Date: Mon, 7 Jan 2019 23:18:40 +0800 Subject: [PATCH] first commit --- 李清宇.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 李清宇.c diff --git a/李清宇.c b/李清宇.c new file mode 100644 index 0000000..6ec5635 --- /dev/null +++ b/李清宇.c @@ -0,0 +1,107 @@ +#include +#include +#include +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");// + 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("***********˵************\n"); + printf("*********1:Ʒ*********\n"); + printf("*********2:Ʒ*********\n"); + printf("*********3:¿*********\n"); + printf("*********4:ѯ*********\n"); + printf("*********5:ͳ*********\n"); + printf("*********6:˳ϵͳ*********\n"); + printf("*********ѡ*********\n"); + printf("----------------------------\n"); +} + + void input() +{ + char next='y'; + part1=fopen("storg","rb+"); + if(part1==NULL) + { + part1=fopen("storg","wb+"); + if(part1==NULL) + { + printf("ļʧ\n"); + exit(0); + } + } + //fseek(part1,0,SEEK_END); + while(next=='y') + { + printf("\nƷ\n"); + gets(g.num ); + printf("\nƷ\n"); + gets(g.name ); + printf("\nƷ۸\n"); + scanf("%lf",&g.price ); + fprintf(part1,"%10s%10s%10s",g.num ,g.name ,g.price );/*ļд*/ + printf("\n루y/n\n"); + fflush(stdin);//ջ + next=getch(); + } + fclose(part1); +} + void check() +{ + part1=fopen("storg","rb+"); + if(part1==NULL) + { + printf("ļʧ\n"); + exit(1); + } + rewind(part1); + printf("\n\nƷб\n****************\n"); + printf("id name price\n"); + while(!feof(part1)) + { + fscanf(part1, "%10s%10s%10s",g.num ,g.name ,&g.price); + //ļݵṹ + printf("%-10s %-10s %-10f\n",g.num ,g.name ,g.price); + } + fclose(part1); +} + + +