【简答题】【消耗次数:1】
统计整数n的各个位上出现数字1、2、3的次数,并通过外部(全局)变量c1、c2、c3返回主函数。 例如,当n=123114350时,结果应该为:c1=3 c2=1 c3=2。 #includeint c1,c2,c3; void fun(long n) { c1 = c2 = c3 = 0; while (n) { /************found************/ switch([填空1]) { case 1: c1++; break; /************found************/ case 2: c2++;[填空2] case 3: c3++; } n /= 10; } } main() { int n=123114350; fun(n); printf(\nn=%d c1=%d c2=%d c3=%d\n,n,c1,c2,c3); }
参考答案:
复制
纠错
相关题目
【单选题】 若有语句char c1=`d`,c2=`g`;printf(“%c,%d\n”,c2-`a`,c2-c1);则输出结果为:()(a的ASCII码值为97)
①  M、2
②  G、3
③  G、2
④  D、g
【简答题】 有以下程序(说明:字符0的ASCII码值为48)#includestdio.hmain(){ char c1,c2;scanf(%d,c2=c1+9;printf(%c%c\n,c1,c2); }若程序运行时从键盘输入48回车,则输出结果为[填空1]。
【单选题】 巳知字母A的ASCII码是65,以下程序的执行结果是()#includestdio.hmain(){charc1=A,c2=Y;printf("%d,%d\n",c1,c2);
①  A,Y
②  65,65
③  65,90
④  65,89
【单选题】 有以下程序: main( ) { int c; while((c=getchar( ) ) != \n ) { switch(c- 2 ) { case 0 : case 1 : putchar(c+4) ; case 2 : putchar(c+4) ; break; case 3 : putchar(c+3) ; default: putchar(c+2) ; break; } } printf(\n } 当输入: 247, 程序的输出结果是()。
①  689
②  6689
③  66778
④  66887
【单选题】 下述程序的运行结果( )。 #includevoid main() { int a=1,b=2,c=3; if(c=a)printf(%d\n else printf(%d\n }
①  1
②  3
③  5
④  6
【单选题】 设:inta=1,b=2,c=3,d=4,m=2,n=2;执行(m=a>b)&&(n=c>d)后n的值为()。
①  1
②  2
③  3
④  4
【单选题】 下述程序的运行结果( )。 #includevoid main() { int a=5,b=4,c=3,d=2; if(ac)printf(%d\n else if((c-1=d)==1)printf(%d\n,d+1); else printf(%d\n,d+2); }
①  0
②  1
③  2
④  3
【单选题】 下述程序的运行结果( )。 #includevoid main() { int a=5,b=4,c=3,d=2; if(ac)printf(%d\n else if((c-1=d)==1)printf(%d\n,d+1); else printf(%d\n,d+2); }
①  1
②  2
③  3
④  4
【单选题】 有以下程序:main(){intc;while((c=getchar())!=\n){switch(c-2){case0:case1:putchar(c+4);case2:putchar(c+4);break;case3:putchar(c+3);default:putchar(c+2);break;}}printf("\n");}当输入:247回车,程序的输出结果是()。
①  689
②  6689
③  66778
④  66887
【单选题】 用Y/C1/C2表示的彩色电视信号称为( )。
①  分量信号
②  复合视频信号
③  分离电视信号S-Video
④  全电视信号
随机题目
【单选题】 Computer classes must be __________ to every student of all grades, which will make them have a good command of the modern communication and learning tool.
①  accessible
②  avoidable
③  valuable
④  acceptable
【单选题】 Peter’s mother kept telling him that he should give up smoking, but _____ didn’t help.
①  he
②  which
③  she
④  it
【单选题】 Not until he went through real hardship the love we have for our families is important.
①  had he realized
②  did he realize
③  he realized
④  he had realized
【单选题】 —I knocked over my coffee cup. It went right over _____ keyboard.—You shouldn’t put drinks near _____ computer.
①  the; /
②  the; a
③  a; /
④  a; a
【单选题】 The letters for the boss __________ on his desk but he didnt read them until three days later.
①  were put
②  was put
③  put
④  has put
【单选题】 Someone called me up in the middle of the night, but they hung up _____ I could answer the phone.
①  as
②  since
③  until
④  before
【单选题】 Is the hotel _____ offered you a job _____ you stayed the first time you arrived here?
①  which; where
②  the one; in which
③  where; that
④  the one that; which
【单选题】 —Have you heard about that fire in the market?—Yes, fortunately no one __________.
①  hurt
②  was hurt
③  has hurt
④  had been hurt
【判断题】 It is not so cold as yesterday.
①  正确
②  错误
【判断题】 It is raining this morning.
①  正确
②  错误