这样写代码会存在隐患吗?结果是正确的?这样的习惯怎样啊?
#include <stdio.h>void test(int b);
void main()
{
int a = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};
test(a);
putchar('\n');
}
void test(int b)
{
int v=0,i;
for( i=0; i<=9; i++ )
{
v=v+b;
}
v=v/10;
printf("%d",v);
}
{:5_111:}求十个数的平均数。 好乱的说
#include <stdio.h>
void test(int b);
void main()
{
int a = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};
test(a);
putchar('\n');
}
void test(int b)
{
int v=0,i;
for( i=0; i<=9; i++ )
{
v=v+b;
}
v=v/10;
printf("%d",v);
}
{:5_100:}这样好点了看的清楚 {:5_111:}{:5_111:}形参数组不定义长度是不是没问题啊?试了一下没问题的吗?是不是真的没问题?
{:5_109:} shaoguanfa 发表于 2014-12-29 12:07
形参数组不定义长度是不是没问题啊?试了一下没问题的吗?是不是真的没问题?
{:5_109: ...
你确定能正常运行? 输出结果11
感觉没问题但是写的代码和视频里面的区别挺大的不知道对不对{:5_111:} 小甲鱼的二师兄 发表于 2014-12-29 12:19
你确定能正常运行?
感觉没问题但是写的代码和视频里面的区别挺大的不知道对不对 v=v/10; printf("%d",v); 你能百分百保证没有小数点吗 最好这样哦!
int main()
{
return 0;
} shaoguanfa 发表于 2014-12-29 12:04
好乱的说
这样好点了看的清楚
自己去查查,C语言的数组是如何作为参数传递的。你的这个程序也就是可以运行而已,如果是笔试的话,这个数组的参数传递方式可以让公司直接决定不录用你,根本不需要继续看其它东西。
页:
[1]