C程序通过mysql拉取
我有这段代码来查找某些输入值的平均值和标准差。但这是一个静态程序。我想通过 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"]; if [[abs[mean_ih-test_h]I have this code to find the mean and standard deviation of some input values. But it's a static program. I want to pull this through a MySQL database and use it. Can you help me out?
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;
/* POPULATING THE INDIAN DATABASE */
indian[i][j]=random[]/DIV;
/POPULATING THE CHINESE DATABASE/
china[i][j]=random[]/DIS;
Finding the MEAN of the Indian and the Chinese Data
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;
To find the Standard Deviation of the entries
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];
Prompting the user to enter data to verify
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"];
if [[abs[mean_ih-test_h]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在此处查看 mySQL C API 文档如何通过C程序连接MySQL数据库。
如需教程,您还可以查看此。
You will need to look at the mySQL C API documentation here for how to connect to a MySQL database through a C program.
For a tutorial, you can also take a look at this.