You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
3.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<stdio.h>
int C[5] = {1, 2, 3, 4, 5};
int main()
{
int M[4][5]={{110,120,130,140,150},{111,121,131,141,151},{112,122,136,142,152},{113,123,133,143,153}};
int S[4][5]={{100,110,120,130,140},{101,111,121,131,141},{102,112,122,132,141},{103,113,123,133,143}};
int a,n,m,b,c,x,y,shou,chan,t;
int f[5],g[5];
int product=0, sales=0;
printf("显示每种产品每周生产值和销售值,请输入1\n");
printf("显示所有产品每周的生产值和销售值请输入2\n");
printf("显示每种产品一个月内的生产值和销售值请输入3\n");
printf("显示所有产品生产总值和销售总值请输入4\n");
printf("退出请输入5\n");
//printf("修改生产值数据,请输入6\n");
//printf("修改销售值数据,请输入7\n");
out:
printf("请输入数字,选择别的功能\n");
scanf("%d",&a);
switch(a){
case 1:
printf("每种产品每周的生产值\n");
//printf("\n");
for(n=0;n<4;n++){
printf("Week(%d)",n+1);
for(m=0;m<5;m++){
printf(" %d",M[n][m]);
}
printf("\n");}
printf("每种产品每周的销售值\n");
//printf("\n");
for(b=0;b<4;b++){
printf("Week(%d)",b+1);
for(c=0;c<5;c++){
printf(" %d",S[b][c]*C[c]);
}
printf("\n");
}
goto out;
break;
case 2:
printf("每周所有产品的生产值和销售值\n");
printf(" 生产值");
printf(" 销售值\n");
for(n=0;n<4;n++){
printf("Week(%d)",n+1);
x=0;
for(m=0;m<5;m++){
x+=M[n][m];
}
t=0;
for(b=0;b<5;b++){
y+=S[n][b];
t+=(S[n][b]*C[b]);
shou+=t;
}
printf(" %d",x);
printf(" %d",t);
printf("\n");}
goto out;
break;
case 3:
printf("每种产品一个月内的生产值和销售值\n");
printf(" 生产值");
printf(" 销售值\n");
for(m=0;m<5;m++){
f[m]=0;
g[m]=0;
printf("Product(%d)",m);
for(n=0;n<4;n++){
f[m]+=M[n][m];
}
for(b=0;b<4;b++){
g[m]+=S[b][m];
}
printf(" %d",f[m]);
printf(" %d",g[m]);
printf("\n");}
goto out;
break;
case 4:
printf("所有产品一个月的生产总值和销售总值\n");
for(n=0;n<4;n++){
for(m=0;m<5;m++){
product+=M[n][m];
}
for(b=0;b<5;b++){
sales+=S[n][b];
}
}
printf("Total product = %d\n",product);
printf("Total sales = %d\n",sales);
goto out;
break;
case 5:
printf("退出\n");
break;
/*case 6:
printf("输入需要修改的生产值\n");
for(n=0;n<4;n++){
for(m=0;m<5;m++){
printf("%d ",M[n][m]);
if(m==4)
printf("\n");
}
}
printf("选择第几行几列\n");
scanf("%d %d",&a,&b);
printf("请输入修改后的值\n");
scanf("%d",&c);
M[n][m]=c;
goto out;
break;
case 7:
printf("输入需要修改的销售值\n");
for(n=0;n<4;n++){
for(m=0;m<5;m++){
printf("%d ",S[n][m]);
if(m==4)
printf("\n");
}}
printf("选择第几行几列\n");
scanf("%d %d",&a,&b);
printf("请输入修改后的值\n");
scanf("%d",&c);
S[n][m]=c;
goto out;
break;*/
}
}