2016-2018年中央财经大学C语言程序设计考研真题及答案解析(8)

本站小编 免费考研网/2020-03-02


                      case 8:printf("B");break;
                      case 7:printf("C");break;
                      case 6:printf("D");break;
                                         printf("E");
                 }
            }
3、下面程序是在两位数中统计所有能被3整除的数的个数。
            main()
            {    int i,num=0;
                 for(i=10;i<100;i++)
                   if(                      )
                      num++;
                 printf("\nThere are%d numbers!",num);
            }
4、以下程序段的输出结果是                     。
            main()
            {    int  x=3;
                 do
                 {    printf("%3d",x-=2);
                 }while(!(--x));
                 }
5、以下程序的输出结果是                     。
            main()
            {    int a=-1,b=4,k;
                 k=(++a<0)&&!(b--<=0);
                 printf("%d%d%d\n",k,a,b);
            }
6、下列程序执行后输出的结果是                      。
            #include<stdio.h>
               f(int a)
               {  int b=0;
                     static  c=3;
                       a=c+ +,b++;
                     return(a);
             }
                   main( )
                {  int a=2,i,k;
                      for(i=0;i<2;i++)
                           k=f(a++);
                      printf("%d\n",k);
             }
7、阅读程序,请写出结果:
            main( )
            {    int  x,y;
                 scanf("%d",&x)
                 y=-1;
                      if(x!=0)
                      if(x>0)y=1;
                    else   y=0;
                      printf("y=%d\n",y);
            }
    若运行该程序,输入值为:5<CR>,则输出结果为:                      。
8、阅读程序,请写出结果:
            main( )
               {  char  c;
                       int  s1=0,s2=0;
                       do
                  {swith(c=getchar())
                      {    case'a':
                      case'e':
                      case'x':
                      case'o':
                      case'u':s1+=1;
                      default:  s2+=1;
                      }
                   }while(c!='\n');
                        printf("%d.%d\n",s1,s2);
                }
    若输入数据为:computer<CR>,则输出结果为:                      。
9、阅读程序,请写出结果:
            main( )
               {  int  m,  i,  k;
                  scanf("%d",&m);
                  for(i=2;i<m;i++)
                  if(m%i= =0)  break;
                       if(i>=m)
                      printf("%d\n",m);

相关话题/中央财经大学 语言 程序 设计