递归求输入和 为什么总提示函数定义错误
#include<stdio.h>void main()
{
void test(int *sum);
int s;
scanf("%d",&s);
test(&s);
printf("%d",s);
void test(int *sum)
{
int x;
scanf("%d",&x);
if(x==0)
*sum=0;
else
{
test(sum);
*sum+=x;
}
}
}
2011-11-01 22:49
2011-11-01 23:05
程序代码:#include<stdio.h>
void main()
{
void test(int *sum);
int s;
puts("请输入要加的数:输入0结束.");
test(&s);
printf("%d",s);
}
void test(int *sum)
{
int x;
scanf("%d",&x);
if(x==0)*sum=0;
else
{
test(sum);
*sum=x+(*sum);
}
}
你这个递归可把我弄晕了 看了好就才会的 ....汗啊.
2011-11-02 18:51
2011-11-02 19:20
2011-11-02 20:43
2011-11-02 23:16