填空题
函数fun的功能是:统计长整数n的各位上出现数字1、2、3的次数,并用外部(全局)变量c1、c2、c3返回主函数。
例如,当n=123114350时,结果应该为:c1=3 c2=1 c3=2。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
int c1, c2, c3;
void fun(long n)
{
c1=c2=c3=0;
while(n)
{
/**********found**********/
switch(
1)
{
/**********found**********/
case 1:c1++;
2;
/**********found**********/
case 2:c2++;
3;
case 3:c3++;
}
n/=10;
}
}
main()
{
10ng n=123114350L;
fun(n);
printf("/nThe result:/n");
printf("n=%ld c1=%d c2=%d c3=%d/n", n, c1, c2, c3);
}