一个数据处理软件
本软件包含数据模型建立、平均值计算、偶然误差和残余误差计算、单词测量和算术平均值标准差计算下面是用户界面:
target="_blank"><img src="http://i. border="0"></a>" border="0" />
代码如下:
#include<stdio.h>
#include<math.h>
#include<conio.h>
#define N 100
#define M 3
void instruction(void)
{
window(5,5,75,21);
textbackground(BLUE);
clrscr();
textcolor(WHITE);
printf(" ********* INSTRUCTIONS *********\n");
printf(" -------------------------------------------------------------------\n");
printf(" ->Edtion:V0.0.2\n");
printf(" ->Author:XiangDong you \n");
printf(" ->E-mail:hlmzrdongdong@\n");
printf(" ->Attention:only run on TC2.0,cann't run on VC++\n");
printf(" -------------------------------------------------------------------\n\n");
printf(" >>>>>>>>>>>>> MAIN MENU <<<<<<<<<<<\n");
printf(" -------------------------------------------------------------------\n");
printf(" 1->Build the datas model\n");
printf(" 2->Calculate the averagevalue\n");
printf(" 3->Calculate the errorvalue\n");
printf(" 4->Calculate the per_standard or averagevaluestandard errorvalue \n");
printf(" -------------------------------------------------------------------\n");
printf("\n Press any key to contiune!");
}
struct data
{
float value[N];
float errorvalue[N];
float averagevalue;
float standardvalue;
float per_standardvalue;
};
struct data1
{
float value[N];
float errorvalue[N];
float averagevalue;
float standardvalue;
float per_standardvalue;
};
int build_Data(struct data *pp)
{
int realN;
int i;
window(5,5,75,21);
textbackground(BLUE);
clrscr();
textcolor(WHITE);
cprintf("1->Build the datas model\n");
cprintf("\r ->Please input the total number of the datas:");
scanf("%d",&realN);
cprintf("\r ->The total number is:%d\n",realN);
cprintf("\r ->Please input the datas ,seclude by space,ends by Enter:\n\r");
for(i=0;i<realN;i++)
{
cscanf("%f",&pp->value[i]);
}
cprintf("\n\r ->The following is the datas:\n\r");
for(i=0;i<realN;i++)
{
cprintf(" x[%d]=%10.5f ",i,pp->value[i]);
if((i+1)%3==0)cprintf("\n\r");
}
return realN;
}
void Count_averagevalue(struct data *pp,int realN)
{
int i;
window(5,5,75,21);
textbackground(BLUE);
clrscr();
textcolor(WHITE);
cprintf("2->Calculate the averagevalue\n");
pp->averagevalue=0.0;
for(i=0;i<realN;i++)
pp->averagevalue=pp->averagevalue+pp->value[i];
pp->averagevalue=pp->averagevalue/((float)realN);
cprintf("\r ->The averagevalue is:%10.5f\n",pp->averagevalue);
cprintf("\n\r Press any key to contiune!");
}
void Count_standardvalue(struct data *pp,int realN)
{
int i;
int j;
window(5,5,75,21);
textbackground(BLUE);
clrscr();
textcolor(WHITE);
cprintf("4->Calculate the per_standard or averagevalue standard errorvalue\n");
cprintf("\r ->Please choose the formulary:\n");
cprintf("\r 1->Bessel formulary 2->Peters formulary\n");
cprintf("\r Please input the number to choose:");
scanf("%d",&j);
pp->averagevalue=0.0;
for(i=0;i<realN;i++)
{
pp->standardvalue=pp->standardvalue+pp->errorvalue[i]*pp->errorvalue[i];
}
if(j==1)
{
pp->per_standardvalue=sqrt(pp->standardvalue/((float)(realN-1)));
pp->standardvalue=pp->per_standardvalue/sqrt((float) realN);
cprintf("\r ->The per_standard errorvalue is:%f\n",pp->per_standardvalue);
cprintf("\r ->The averagevalue standard errorvalue is:%f\n",pp->standardvalue);
}
else if(j==2)
{
pp->per_standardvalue=1.253*pp->standardvalue/sqrt((float)(realN*(realN-1)));
pp->standardvalue=1.253*pp->standardvalue/(((float)realN)*sqrt((float)(realN-1)));
cprintf("\n\r ->The per_standard errorvalue is :%f\n",pp->per_standardvalue);
cprintf("\r ->The averagevalue standard errorvalue:%f\n\r",pp->standardvalue);
}
}
void Count_errorvalue(struct data *pp,int realN)
{
int i;
float realvalue;
window(5,5,75,21);
textbackground(BLUE);
clrscr();
textcolor(WHITE);
cprintf("3->Calculate the errorvalue\n");
cprintf("\r ->Input the realvalue or input 0 to calculate by averagevalue:");
scanf("%f",&realvalue);
if(realvalue==0)
realvalue=pp->averagevalue;
for(i=0;i<realN;i++)
pp->errorvalue[i]=pp->value[i]-realvalue;
cprintf("\n\r ->The datas' errorvalue is :\n\r");
for(i=0;i<realN;i++)
{
cprintf(" v[%d]=%10.5f ",i,pp->errorvalue[i]);
if((i+1)%3==0)cprintf("\n\r");
}
cprintf("\n\r Press any key to contiune!");
}
void main(void)
{
struct data datas;
struct data *p;
int realN;
p=&datas;
textmode(C80);
textbackground(BLACK);
clrscr();
textcolor(WHITE);
cprintf(" $--------------------------$");
cprintf("\n\r $-- DATA MANAGE SYSTEM --$");
cprintf("\n\r $--------------------------$");
cprintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
cprintf("\r China University of Geosciences\n");
cprintf("\r Copyright @ XiangDong you 062062-21 Oct.27th 2008");
window(2,4,78,22);
textbackground(GREEN);
clrscr();
instruction();
getch();
realN=build_Data(p);
cprintf("\n\n\r Press any key to contiune!");
getch();
getch();
Count_averagevalue(p,realN);
getch();
Count_errorvalue(p,realN);
getch();
Count_standardvalue(p,realN);
}