请教一个问题,这个代码错误在哪呢
#include <stdio.h>double copy_arr (double [], double [], int );
void show_target1 (double [], int );
int main (void)
{
double source = {1.1, 2.2, 3.3, 4.4, 5.5};
double target1;
copy_arr (source, target1, 5);
show_target1 (target1, 5);
return 0;
}
double copy_arr (double a[], double b[], int n )
{
int i;
for (i = 0; i < n; i++)
b = a;
return b;
}
void show_target1 (double a[], int n)
{
int i;
for (i = 0; i < n; i++)
printf ("%ld\n",a);
}//复制进去,再显示出来
#include <stdio.h>
double copy_arr (double [], double [], int );
void show_target1 (double [], int );
int main (void)
{
double source = {1.1, 2.2, 3.3, 4.4, 5.5};
double target1;
copy_arr (source, target1, 5);
show_target1 (target1, 5);
return 0;
}
double copy_arr (double a[], double b[], int n )
{
int i;
for (i = 0; i < n; i++)
b = a;
return b;
}
void show_target1 (double a[], int n)
{
int i;
for (i = 0; i < n; i++)
//printf ("%ld\n",a);//类型不匹配
{
printf("%lf\n",a);
}
}
本帖最后由 machimilk 于 2014-2-14 02:05 编辑
把printf ("%ld\n",a);改成printf ("%f\n",a);
如果非要保持你输入的那种位数就改成printf ("%1.1f\n",a);
具体你百度一下 数据输出格式化样式 路过看看= =! machimilk 发表于 2014-2-14 02:03 static/image/common/back.gif
把printf ("%ld\n",a);改成printf ("%f\n",a);
如果非要保持你输入的那种位数就改成printf ("%1.1f\n",a); ...
THANKS,发现了 牡丹花下死做鬼 发表于 2014-2-14 02:40 static/image/common/back.gif
发现错误了..谢谢!
页:
[1]