C 언어 코드 주문 시스템 구현
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<cstring>
#include<conio.h>
using namespace std;
typedef struct member
{
char username[20];//
char password[20];//
}Member;
typedef struct product
{
char name[20];//
int price;
int num;//
}Product;
/* */
void menu1();/* */
void menu2();/* */
void all_info();//
void member_log_up();//
void member_log_in_interface();//
int member_log_in();//
void check();
/* */
void sell_info();//
void password_manage();//
int compare_password(char password[]);//
int main()
{
int flag1=1,flag_member=0,flag_admin=0;
int choice1,choice2;
while(flag1){
menu1();
printf("
");
printf(" (1-5):");
scanf("%d",&choice1);
if(choice1==1)/* */
{
member_log_in_interface();
flag_member=member_log_in();
while(flag_member)
{
all_info();
check();
}
}
else if(choice1==2)/* */
{
printf("
\t\t\t ...
");
member_log_up();
}
else if(choice1==3)/* */
{
printf(" :");
char password[20]={0};
scanf("%s",password);
if(compare_password(password))
{
printf("
\t\t\t\t -- !--
\t\t\t\t== ==
");
flag_admin=1;
}
else
{
printf("
\t\t\t\t -- !--
");
}
while(flag_admin)
{
menu2();
printf(" (1-3):");
scanf("%d",&choice2);
switch(choice2)
{
case 1:password_manage();break;
case 2:sell_info();break;
case 3:flag_admin=0;break;
}
}
}
else if(choice1==4)/* */
{
flag1=0;
}
}
printf(" !( )
\t !
");
return 0;
}
void menu1()
{
system("color E9");
printf("
");
printf("\t\t\t *=======================================*
");
printf("\t\t\t| * - * - * Zhou Cheng - System - * - * |
");
printf("\t\t\t| * * |
");
printf("\t\t\t| | [1] | |
");
printf("\t\t\t| * * |
");
printf("\t\t\t| | [2] | |
");
printf("\t\t\t| * * |
");
printf("\t\t\t| | [3] | |
");
printf("\t\t\t| * * |
");
printf("\t\t\t| | [4] | |
");
printf("\t\t\t| * * |
");
printf("\t\t\t| * - * - * - * - * - * - * - * - * - * |
");
printf("\t\t\t *=======================================*
");
}
void menu2()
{
printf("
");
printf("\t\t\t *======================================*
");
printf("\t\t\t| | * - * - * - - - - * - * - * | |
");
printf("\t\t\t| * * |
");
printf("\t\t\t| | [1] | |
");
printf("\t\t\t| * [2] * |
");
printf("\t\t\t| * [3] * |
");
printf("\t\t\t| | | |
");
printf("\t\t\t| * - * - * - * - * -- * - * - * - * - * |
");
printf("\t\t\t *======================================*
");
}
int compare_password(char password[])/* */
{
int i,flag=1;
for(i=0;i<6;i++)
{
if(password[i]!='1'+i)flag=0;
}
return flag;
}
void member_log_up()//
{
Member member;
while(1)
{
printf(" username( ):");
scanf("%s",member.username);
printf(" (20 ):");
scanf("%s",member.password);
printf(" (y/n):");
char ch=getch();
if(ch=='n')continue;
else if(ch=='y')
{
FILE *fp=fopen("memberInfo.txt","a+");
fprintf(fp,"%s %s ",member.username,member.password);
fclose(fp);
printf("
!
");
printf("-------- --------");
return ;
}
}
}
int member_log_in()
{
Member member[100];
FILE *fp=fopen("memberInfo.txt","a+");
int i=0;
while(!feof(fp))
{
fscanf(fp,"%s %s",member[i].username,member[i].password);
i++;
}
char username[20],password[20];
scanf("%s",username);
printf("\t\t\t (password):");
scanf("%s",password);
int flag=0;
for(int j=0;j<i;j++)
{
if(strcmp(username,member[j].username)==0&&strcmp(password,member[j].password)==0)
{
flag=1;
break;
}
}
return flag;
}
void member_log_in_interface()/* */
{
printf("
\t\t\t***================================***
");
printf("\t\t\t
");
printf("\t\t\t (username):");
}
void all_info()
{
Product product[100];
FILE *fp=fopen("productInfo.txt","a+");
int i=0;
while(!feof(fp))
{
fscanf(fp,"%s %d %d",product[i].name,&product[i].price,&product[i].num);
i++;
}
printf(" -- --------- ---
");
for(int j=0;j<i;j++)
{
printf("%-6d%-15s%-7d
",j+1,product[j].name,product[j].price);
}
printf(" ( ):");
int num,count;
scanf("%d %d",&num,&count);
printf(" ...
");
printf(" :");
char c;
scanf(" %c",&c);
}
void sell_info()
{
Product product[100];
FILE *fp=fopen("productInfo.txt","a+");
int i=0;
while(!feof(fp))
{
fscanf(fp,"%s %d %d",product[i].name,&product[i].price,&product[i].num);
i++;
}
printf("-- --------- --- --- --
");
for(int j=0;j<i;j++)
{
printf(" %-15s%-7d%-9d%-8d
",product[j].name,product[j].price,product[j].num,product[j].price*product[j].num);
}
printf(" :");
char c;
scanf(" %c",&c);
}
void password_manage()
{
Member member[100];
FILE *fp=fopen("memberInfo.txt","a+");
int i=0;
while(!feof(fp))
{
fscanf(fp,"%s %s",member[i].username,member[i].password);
i++;
}
printf("---- ------------ ----------");
for(int j=0;j<i;j++)
{
printf("
%-17s %-15s",member[j].username,member[j].password);
}
printf(" :");
char c;
scanf(" %c",&c);
}
void check()
{
printf(" ...
");
printf(" :");
char c;
scanf(" %c",&c);
}
더 많은 학습 자 료 는 주제 인 에 주목 하 세 요.이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C 언어 구현 천둥 제거 게임 상세 정보먼저 작은 메뉴를 표시하고 게임을 할지 여부를 선택하십시오.사용자가 종료를 선택하면 프로그램 실행이 끝나고, 사용자가 게임을 선택하면 지뢰 제거 위치 좌표를 입력하라는 메시지가 표시됩니다.사용자가 입력한 좌표가 바둑...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.