// SALES.cpp : 定义控制台应用程序的入口点。
//
#include
#include "stdafx.h"
struct SALES
{
char pno[5];
char pname[9];
double sale1,sale2,sale3;
};
void Total( SALES data[] ,int n )
{
char a;
int goods,i;
double j,count[30];
goods = n;
printf("商品编号 商品名称 一月份 二月份 三月份 季度会计\n");
for ( i=0 ; i {
count[i] = 0;
count[i] = data[i].sale1 + data[i].sale2 + data[i].sale3 ;
printf("%5s%9s %.2lf %.2lf %.2lf %.2lf\n",data[i].pno,data[i].pname,data[i].sale1,data[i].sale2,data[i].sale3,count[i]);
}
printf(" 总计");
for( i=0,j=0 ; i {
j = j + data[i].sale1;
}
printf(" %.2lf",j);
for( i=0,j=0 ; i {
j = j + data[i].sale2;
}
printf(" %.2lf",j);
for( i=0,j=0 ; i {
j = j + data[i].sale3;
}
printf(" %.2lf",j);
for( i=0,j=0 ; i {
j = j + count[i];
}
printf(" %.2lf\n",j);
getchar();
}
int _tmain(int argc, _TCHAR* argv[])
{
SALES d[]={ {"DQ01","彩电", 302874.37,401298.49,249308.20},
{"DQ02","音响", 406566.46,483434.83,428465.25},
{"DQ03","电冰箱", 230040.34,204542.94,173456.73},
{"DQ04","洗衣机", 43567.00,56743.54,41976.17},
{"DQ05","空调", 474356.35,454673.67,347196.49} };
Total( d,5 );
return 0;
}
--------------------next---------------------
阅读(2503) | 评论(0) | 转发(0) |