首页 文章

C程序通过mysql拉

提问于
浏览
0

我有这个代码来找到一些输入值的均值和标准差 . 但这是一个静态的程序 . 我想通过MySQL数据库将其拉出来并使用它 . 你能帮我吗?

int main[]
[
/* 2-dimensional array is used to store the height,lenght and the width attributes of the nose. indian
array represents
the indian data and the china array represents the chinese data */
/* Mean variable represents the mean values. The subscripts are used to identify indian and chinese
attributes */
float indian[MAX][3],china[MAX]
[3],mean_ih=0,mean_il=0,mean_iw=0,mean_ch=0,mean_cl=0,mean_cw=0;
/* Following float variables store the standard deviation values */
float sd_ih=0,sd_il=0,sd_iw=0,sd_ch=0,sd_cl=0,sd_cw=0;
int i,j;
float test_h,test_l,test_w;

/ 推广印度数据库 /

indian[i][j]=random[]/DIV;

/播放中文数据库/

china[i][j]=random[]/DIS;

寻找印度和中国数据的平均值

mean_ih+=indian[i][0];
mean_il+=indian[i][1];
mean_iw+=indian[i][2];
mean_ch+=china[i][0];
mean_cl+=china[i][1];
mean_cw+=china[i][2];
mean_ih=mean_ih/MAX; mean_il=mean_il/MAX; mean_iw=mean_iw/MAX;
mean_ch=mean_ch/MAX; mean_cl=mean_cl/MAX; mean_cw=mean_cw/MAX;

查找条目的标准偏差

sd_ih+=pow[[indian[i][0]-mean_ih],2];
sd_il+=pow[[indian[i][1]-mean_il],2];
sd_iw+=pow[[indian[i][2]-mean_iw],2];
sd_ch+=pow[[china[i][0]-mean_ch],2];
sd_cl+=pow[[china[i][1]-mean_cl],2];
sd_cw+=pow[[china[i][2]-mean_cw],2];

sd_ih=sqrt[sd_ih/MAX]; sd_il=sqrt[sd_il/MAX]; sd_iw=sqrt[sd_iw/MAX];
sd_ch=sqrt[sd_ch/MAX]; sd_cl=sqrt[sd_cl/MAX]; sd_cw=sqrt[sd_cw/MAX];

提示用户输入要验证的数据
printf [" \n ============================================================\n"]; printf [" \n Enter the Height \n"]; scanf [" %f",&test_h]; printf [" \n ============================================================\n"]; printf [" \n Enter the length \n"]; scanf ["%f",&test_l]; printf [" \n ============================================================\n"]; printf [" \n Enter the width \n "]; scanf ["%f",&test_w]; printf [" \n ============================================================\n"];如果[[abs [mean_ih-test_h]

1 回答

  • 0

    您需要查看mySQL C API文档here,了解如何通过C程序连接到MySQL数据库 .

    有关教程,您还可以查看this .

相关问题