当前位置:网站首页>Design of sales management system for C language course (big homework)
Design of sales management system for C language course (big homework)
2022-07-01 06:25:00 【Ordinary senior】

One 、 Design function ( The article is for reference only )
Try to design a note management system , It can provide the following functions :
1、 The system works as a menu
2、 Note information entry function ( Note information is saved in a file )-- Input
3、 After collecting all the notes from last month , Read sales
1) Calculate the sales of each product for each person .
2) Sort salesmen by sales , Output sorting results ( Salesman code )
3) Count the total sales of each product , For these products, from top to bottom , Output sorting results ( Need to output product code and sales )( optional )
Two 、 Function display



3、 ... and 、 Mind mapping

Four 、 Program source code
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#define Z 5
#define R 4 /* Defining macro constants facilitates the generalization of programs */ /*R Indicates the number of salesmen */
typedef struct /* Shorten the structure variable name */
{
int shangpin[Z]; /* Define the structure to facilitate the storage, reading and writing of information , identify */
}data; /*R It means the kind of goods , The last one is the total of the salesperson's products */
void menu()
{
system("cls"); /* Clear screen command */
printf("\n\n");
printf("\t ┏━━━━━━━━━━━━ The main menu ━━━━━━━━━━┓\n");
printf("\t ┃ 1. Calculate the sales of each product per person last month ┃\n");
printf("\t ┃ 2. Sort salesmen by sales , Output sorting results ┃\n");
printf("\t ┃ 3. Count the total sales of each product , Output sorting results ┃\n");
printf("\t ┃ 4. Output statistical reports ┃\n");
printf("\t ┃ 5. End operation ┃\n");
printf("\t ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
}
void f1(data *x) /* Calculate the sales of each product per person last month */
{
FILE *fp;
char fname[10],hitkey;
int j,t; /* Used to control the cycle */
int i,k,s; /* Used to define employee serial number , Product serial number , Product quantity */
system("cls"); /* Clear screen command */
printf(" Which month do you want to calculate ?\n");
printf(" Please enter the month :"); /* Input file name , In this way, the information of each month can be written */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"wb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0); /* normal exit(0); End procedure */
}
for(j=0;j<R;j++) /* Clear the commodity quantity */
for(t=0;t<Z;t++)
(x+j)->shangpin[t]=0;
printf(" Please enter :\n Employee number Product number sales volumes \n"); /* Prompt the user to write the format of the information */
for(j=0;hitkey!=27;j++)
{
scanf("%d%d%d",&i,&k,&s);
if(i>R||i<0||k>Z||k<0)
{
printf(" Wrong information !\n"); /* Hint , Avoid input errors */
continue;
}
else
(x+i-1)->shangpin[k-1]=(x+i-1)->shangpin[k-1]+s; /* Count the quantity of various products of each individual ,-1 To match the ordinal number in the array */
printf(" To continue typing, press enter , To finish typing, press esc\n");
printf("━━━━━━━━━━━━━━━━━━━━━━\n");
hitkey=getch();
for (;hitkey!=13&&hitkey!=27;)
hitkey=getch();
}
for(j=0;j<R;j++)
if(fwrite((x+j),sizeof(data),1,fp)!=1) /* Write the information into the file and you will be called later */
printf("write error!\n");
fclose(fp); /* Close the file to avoid missing information */
printf("\n\n\n\n\n\n\t\t\t Saved successfully , Press any key to return to the main menu !");
getch();
}
void f2(data *x) /* Sort salesmen by sales , Output sorting results */
{
FILE *fp;
char fname[10];
int i,k,j,t,bianhao[R]={
0},z;
system("cls"); /* Clear screen command */
printf(" Which month do you want ?\n");
printf(" Please enter the month :"); /* Input file name , In this way, the information of each month can be read */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0);
}
for(i=0;i<R;i++) /* Read the message */
if(fread(x+i,sizeof(data),1,fp)!=1)
printf(" Error reading information !"); /* Read in information prompt */
for(i=0;i<R;) /* Used to store employee numbers */
bianhao[i]=i++;
printf(" Please enter by which product \n");
scanf("%d",&k);
k=k-1; /* It is convenient to correspond to the array value in the structure */
for(i=0;i<R;i++) /* Press K Sort salespeople by product , Sorting by selection */
{
t=i;
for(j=i+1;j<R;j++)
if((x+bianhao[t])->shangpin[k]<(x+bianhao[j])->shangpin[k])/* Call the number of products in the corresponding structure of employees */ t=j;
if(t!=i)
{
z=bianhao[i];
bianhao[i]=bianhao[t];
bianhao[t]=z;
}
}
printf("\t\t\t Press %d The order of products to salespeople is :\n",k+1);
printf("━━━━━━━━━━━━━━━━━━━━━\n");
for(i=0;i<R;i++)
printf("\t\t\t The first %d The name is : staff %d\n",i+1,bianhao[i]+1);
printf("\n\n\n\t\t\t Press any key to return to the previous main menu !");
getch();
fclose(fp); /* Close the read in file */
}
void f3(data *x) /* Count the total sales of each product , Output sorting results */
{
FILE *fp;
char fname[10];
int i,j,sum[Z]={
0},bianhao[Z]={
0},z,t,k;
system("cls"); /* Clear screen command */
printf(" Which month do you want to calculate ?\n");
printf(" Please enter the month :"); /* Input file name , In this way, the information of each month can be read */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0);
}
for(i=0;i<R;i++) /* Read the message */
if(fread(x+i,sizeof(data),1,fp)!=1)
printf(" Error reading information !");
for(i=0;i<Z;i++) /* Sum up all kinds of goods */
for(j=0;j<R;j++)
sum[i]=sum[i]+(x+j)->shangpin[i];
for(i=0;i<Z;) /* Used to store item numbers */
bianhao[i]=i++;
for(i=0;i<Z;i++)
printf("%3d",bianhao[i]);
for(i=0;i<Z;i++) /* Rank products from high to low , Sorting by selection */
{
t=i;
for(j=i+1;j<Z;j++) /* When the product changes , The product number also changes , Easy to output */
if(sum[t]<sum[j])
t=j;
if(t!=i)
{
k=sum[i];
sum[i]=sum[t];
sum[t]=k;
z=bianhao[i];
bianhao[i]=bianhao[t];
bianhao[t]=z;
}
}
printf(" Output product sorting \n");
printf(" Product number Number \n");
printf("━━━━━━━━━━━━━\n");
for(i=0;i<Z;i++)
printf(" product %-7d%-1d\n",bianhao[i]+1,sum[i]);
printf("\n\n\n\t\t\t Press any key to return to the main menu !");
getch();
fclose(fp); /* Close the read in file */
}
void f4(data *x) /* Output statistical reports */
{
FILE *fp;
char fname[10];
int i,j,sum[Z+1]={
0};
system("cls"); /* Clear screen command */
printf(" Which month do you want to calculate ?\n");
printf(" Please enter the month :"); /* In fact, enter a file name , In this way, the information of each month can be read */
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /* Open file */
{
printf(" Can't open file !!!\n");
exit(0);
}
for(i=0;i<R;i++) /* Read the message */
if(fread(x+i,sizeof(data),1,fp)!=1)
printf(" Error reading information !");
for(i=0;i<Z;i++) /* Sum up all kinds of goods */
for(j=0;j<R;j++)
sum[i]=sum[i]+(x+j)->shangpin[i];
for(i=0;i<Z;i++) /* Sum up goods */
sum[Z]=sum[Z]+sum[i];
printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
printf(" The output statistical report is as follows :\n"); /* Output statistics as required */
printf(" Salesman code Product code Sum of sales \n");
for(i=0;i<R;i++)
for(j=0;j<Z;j++)
printf(" staff %-8d product %-6d Number %-10d\n",i+1,j+1,(x+i)->shangpin[j]);
printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
for(i=0;i<Z;i++)
{
if(i==0)
printf(" product %d The sum of the %-10d The sum of the %-10d\n",i+1,sum[i],sum[Z]);
else
printf(" product %d The sum of the %-10d\n",i+1,sum[i]);
}
printf("\n\n\n\t\t\t Press any key to return to the main menu !");
getch();
}
main()
{
int i,choice;
data sxy[R]; /*R Indicates the number of employees , The previous macro constants */
printf("\n\n\n\n\n\n\t━━━━━━━━━━━━━━━━━━━━━━━━━\n");
printf("\t--------------- Welcome to the commodity sales system !-------------\n");
printf("\t━━━━━━━━━━━━━━━━━━━━━━━━━\n");
printf("\n\n\n\n\n\n\t\t\t Press any key to enter the main menu !");
getch();
for(i=0;;i++)
{
system("cls"); /* Clear screen command */
menu(); /* The main menu function prompts the user how to choose */
printf(" What do you want to do ?\n");
printf(" Please select :"); /* Enter the operation to be performed */
scanf("%d",&choice);
if(choice==5)
{
system("cls"); /* Clear screen command */
printf("\n\n\n\n\n\n\t━━━━━━━━━━━━━━━━━━━━━━━━━\n\n");
printf("\t--------------- Thank you for using the commodity sales system !-------------\n\n");
printf("\t━━━━━━━━━━━━━━━━━━━━━━━━━\n\n");
printf("\n\n\n\n\n\n\t\t\t Press any key to exit !(^.^)");
getch();
break; /* Quit the whole program */
}
else
switch(choice)
{
case 1 : f1(sxy); break; /* Calculate the sales of each product per person last month */
case 2 : f2(sxy); break; /* Sort the sales of salespersons by sales amount , And output the sorting result */
case 3 : f3(sxy); break; /* Count the total sales of each product , And output the sorting result */
case 4 : f4(sxy); break; /* Output statistical reports */
}
}
}

You can pay attention to it, and it will be updated continuously in the future 0.0( Thank you first )
边栏推荐
- 【Unity Shader 描边效果_案例分享第一篇】
- C语言课设学生信息管理系统(大作业)
- JDBC connection pool
- C#如何打印输出原版数组
- IT服务管理(ITSM)在高等教育领域的应用
- Mysql 表分区创建方法
- SystemVerilog learning-06-class encapsulation
- [automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
- SystemVerilog learning-09-interprocess synchronization, communication and virtual methods
- Diffusion (multi-source search)
猜你喜欢
![[postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map](/img/c0/299a406efea51f24b1701b66adc1e3.png)
[postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map

让厦门灌口镇田头村变甜头村的特色农产品之一是蚂蚁新村

C语言课设工资管理系统(大作业)

To sort out the anomaly detection methods, just read this article!

Mongodb: I. what is mongodb? Advantages and disadvantages of mongodb

B-tree series
![[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform](/img/14/756d566744d6e4a988a284c5b30130.png)
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform

【KV260】利用XADC生成芯片温度曲线图

C语言课设学生考勤系统(大作业)

【Unity Shader 描边效果_案例分享第一篇】
随机推荐
Minio error correction code, construction and startup of distributed Minio cluster
pycharm 配置jupyter
【#Unity Shader#自定义材质面板_第一篇】
ABP 学习解决方案中的项目以及依赖关系
SystemVerilog learning-06-class encapsulation
SQL语句
Discrimination between left and right limits of derivatives and left and right derivatives
How does the port scanning tool help enterprises?
Top 10 Free 3D modeling software for beginners in 2022
Elements of database ER diagram
交换机配置软件具有的作用
[leetcode] day91- duplicate elements exist
Diffusion (multi-source search)
让田头村变甜头村的特色农产品是仙景芋还是白菜
[file system] how to run squashfs on UBI
FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview
Recueillir des trésors dans le palais souterrain (recherche de mémoire profonde)
高阶-二叉搜索树详解
Mongodb: I. what is mongodb? Advantages and disadvantages of mongodb
[summary of knowledge points] chi square distribution, t distribution, F distribution