填空题 给定程序中,函数fun的功能是:找出100至x(x≤999)之间各位上的数字之和为15的所有整数,然后输出;符合条件的整数个数作为函数值返回。 例如,当x值为500时,各位数字之和为15的整数有:159、168、177、186、195、249、258、267、276、285、294、339、348、357、366、375、384、393、429、438、447、456、465、474、483、492,共有26个。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在下的BLANK1.C中。 不得增行或删行,也不得更改程序的结构! 给定源程序: #include <stdio.h> int fun(int x) { int n,s1,s2,s3,t; /**********found**********/ n={{U}} {{U}} {{/U}} {{/U}}; t=100; /**********found**********/ while(t<={{U}} {{U}} {{/U}} {{/U}}) { s1=t%10;s2=(t/10)%10;s3=t/100; if(s1+s2+s3==15) {printf("%d",t); n++; } /**********found**********/ {{U}} {{U}} {{/U}} {{/U}}; } return n; } main() { int x=-1; while(x>999‖x<0) { printf("Please input(0<x<=999):"); scanf("%d",&x);} printf("/nThe result is:%d/n",fun(x)); }
  • 1、
【正确答案】 1、{{*HTML*}}0 x t++
答案考生文件夹    
【答案解析】[解析] (1)变量n用于存放符合条件的整数的个数,应赋初值为0。 (2)根据题目要求,确定循环变量t的取值范围t<=x。 (3)循环变量t自增1操作。