销售管理程序(C语言)

#include <stdio.h>
#include <math.h>
#include <iostream.h>
typedef struct person//销售员
{
 int name;
}person;
typedef struct product//产品
{
 int p_name;
 float p_money;
}product;
typedef struct note//便条
{
 person a;
 product b;
}note;
typedef struct tongji//统计表
{
 int peo_name;
    int pro_money[5];
 int all;
}tongjibiao;
typedef struct chanpintongji//没种产品销售和
{
 int prod;
 int all;
}chanpintongji;

int tongji(note note_a);
int tongjiadd(note note_a,int i);
int chuangjian(note &note_a)
{
 scanf("%d %d %f",&note_a.a.name,&note_a.b.p_name,&note_a.b.p_money);
 return 1;
}
int i;
tongjibiao tongjibiao_1[4];//定义统计表
int tongji(note note_a)
{
 switch(note_a.a.name)
 {
 case 0:
  printf("第0个人");
  tongjiadd(note_a,0);
  break;
 case 1:printf("第1个人");
  tongjiadd(note_a,1);
  break;
 case 2:printf("第2个人");
  tongjiadd(note_a,2);
  break;
 case 3:printf("第3个人");
  tongjiadd(note_a,3);
  break;
 }
 return 0;

}
int tongjiadd(note note_a,int i)
{
switch(note_a.b.p_name)
{case 0:printf("第0个产品");
  tongjibiao_1[i].pro_money[0]+=note_a.b.p_money;
  break;
 case 1:printf("第1个产品");
  tongjibiao_1[i].pro_money[1]+=note_a.b.p_money;
  break;
 case 2:printf("第2个产品");
  tongjibiao_1[i].pro_money[2]+=note_a.b.p_money;
  break;
 case 3:printf("第3个产品");
  tongjibiao_1[i].pro_money[3]+=note_a.b.p_money;
  break;
 case 4:printf("第4个产品");
  tongjibiao_1[i].pro_money[4]+=note_a.b.p_money;
  break;
}
 return 0;
}
void tongjibiao_printf(tongjibiao tongjibiao_1[])//统计表输出
{
 int i,j;
 for(i=0;i!=4;++i)
  for(j=0;j!=5;++j)
   tongjibiao_1[i].all+=tongjibiao_1[i].pro_money[j];
 printf("…………上月销售统计报表如下…………/n");
 printf("销售员代号 1 2 3 4 5 和/n");
 for(i=0;i<=3;i++)
  printf("   %d  %d %d %d %d %d %d/n",i+1,tongjibiao_1[i].pro_money[0],tongjibiao_1[i].pro_money[1],tongjibiao_1[i].pro_money[2],tongjibiao_1[i].pro_money[3],tongjibiao_1[i].pro_money[4],tongjibiao_1[i].all);
}
void tonhjibiao_xsy_print(tongjibiao tongjibiao_1[])//按销售额对销售员排序
{
 int i,j,k,n;
 tongjibiao temp;
 for(i=0;i!=4;++i)
  for(j=0;j!=5;++j)
   tongjibiao_1[i].all+=tongjibiao_1[i].pro_money[j];
 for(i=0;i!=4;++i)
  for(j=i+1;j!=4;++j)
  {
   if(tongjibiao_1[i].all<tongjibiao_1[j].all)
   {
    temp.peo_name=tongjibiao_1[i].peo_name;
    temp.all=tongjibiao_1[i].all;
    for(k=0;k!=5;++k)
     temp.pro_money[k]=tongjibiao_1[i].pro_money[k];

    tongjibiao_1[i].peo_name=tongjibiao_1[j].peo_name;
    tongjibiao_1[i].all=tongjibiao_1[j].all;
    for(k=0;k!=5;++k)
     tongjibiao_1[i].pro_money[k]=tongjibiao_1[j].pro_money[k];

    tongjibiao_1[j].peo_name=temp.peo_name;
    tongjibiao_1[j].all=temp.all;
    for(k=0;k!=5;++k)
     tongjibiao_1[j].pro_money[k]=temp.pro_money[k];
   }
  }
 for(i=0;i!=4;++i)
  printf("%d  ",tongjibiao_1[i].peo_name+1);
 printf("/n");
}
void tonhjibiao_chanping_print(tongjibiao tongjibiao_1[])//按每种产品销售额对产品排序
{
 chanpintongji a[5],temp;
  int k,i;
 for(k=0;k!=5;++k)
 { 
  a[k].prod=k;
  a[k].all=0;
  for(i=0;i!=4;++i)
  {
   a[k].all+=tongjibiao_1[i].pro_money[k];
  } 
 }

 for(k=0;k!=5;++k)
  for(i=k+1;i!=5;++i)
  {
   if(a[k].all<a[i].all)
   {
    temp.all=a[k].all;
    temp.prod=a[k].prod;
    a[k].all=a[i].all;
    a[k].prod=a[i].prod;
    a[i].all=temp.all;
    a[i].prod=temp.prod;
   }
  }
 for(k=0;k!=5;++k)
  printf("%d  %d/n",a[k].prod+1,a[k].all);

}
int main()
{
 char k,m='y',y='y';
 note note_a;
 int i,j,s;
 for(i=0;i!=4;++i)
  tongjibiao_1[i].peo_name=i;
 while(m=='y')
 {
  chuangjian(note_a);
   tongji(note_a);
   printf("/n是否继续输入y/n:");
     // scanf("%c/n",&m);
       cin>>m;
 }
 printf("         …………菜单…………/n");
 printf("1、显示上月每人每种产品产品的统计表/n");
 printf("2、按销售额对销售员排序,并输出销售员排名/n");
 printf("3、按每种产品的总销售额对产品排序,并输出/n");
 while(y=='y')
 {
  scanf("%d",&s);
  switch(s)
  {
   case 1:
   tongjibiao_printf(tongjibiao_1);
   printf("/n");
   break;
   case 2:
   tonhjibiao_xsy_print(tongjibiao_1);
   break;
   case 3:
   tonhjibiao_chanping_print(tongjibiao_1);
   break;
  }
  printf("是否继续操作?y/n");
  //scanf("%c",&y);
  cin>>y;
  if(y=='n')
   break;
 }
    return 0;
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值