给定程序中,函数fun功能是:找出100~999之间(含100和999)所有整数中各位上数字之和为x(x为一正整数)的整数.然后输出;符合条件的整数个数作为函数值返回。
例如,当x值为5时,l00~999之间各位上数字之和为5的整数有:104、113、122、131、140、203、212、221、230、302、311、320、401、410、500。共有15个。当x值为27时,各位数字之和为27的整数是:999。只有1个。
请在程序的下划线处填入正确的内容并把下划线删除.使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLAIIK1.C中。
不得增行或删行.也不得更改程序的结构!
/**********code.c**********/
#include
int fun(int x)
{
int n, s1, s2, s3, t;
n=0;
t=100;
/**********found**********/
while(t<=__1__)
{
/**********found**********/
s1=t%10; s2=(__2__)%10;
s3=t/100;
/**********found**********/
if(s1+s2+s3==__3__)
{
printf("%d ",t);
n++;
}
t++;
}
return n;
}
void main()
{
int x=-1;
while(x<0)
{ printf("Please input(x>0): "); scanf("%d",&x); }
printf("\nThe result is: %d\n",fun(x));
}
/**********-code.c**********/