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

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


            {    int x=8,y=9;
                 int k;
                 k=(x++)+(++y);
                 printf("%d",k);
            }
2、下述程序的输出结果是                  。
            #include<stdio.h>
            int fun(int x)
            {    static int a=3;
                 a+=x;
                 return a;
            }
            main( )
            {    int k=2,m=1,n;
                 n=fun (k);
                 n=fun (m)
                 printf("%d",n);
            }
3、用“冒泡法”对输入的10个字符按由小到大顺序排序,请填空。
           #include<stdio.h>
           #include<conio.h>
           #define n 10
           main()
           {    int i,j;
                char str[11];
                scanf("%s",str);
                char t;
                for(j=1;j<n;j++)
                for(i=0;(i<n-j)&&(str[i]!='\0');i++)
                if(                            )
                {    t=str[i];
                     str[i]=str[I+1];
                     str[i+1]=t;
                }
             for(i=0;i<n;i++)
                printf("%c",str[i]);
           }
4、把字符数组中的字符串按反序存放,例如:字符串"ABCD"的输出结果应为"DCBA",请填空。
            #include<stdio.h>
            #include<conio.h>
            #include<string.h>
            main()
            {
                char a[100],t;
                printr(“输入字符串:\n”);
                scanf("%s",a);
                int i,j;
                for(i=0,j=strlen(a);i<strlen(a)/2;i++,j--)
                {    t=a[i];
                     a[i]=a[j-1];
                                              ;
                }
                printf(“转换后的字符串是:%s\n”,a);
            }
5、下面程序的执行结果是                   。
            #include<stdio.h>
            main( )
            {    int array[ ][3]={{10,20,30},{28,15.-10},{-50,10,60}};
                 int i,j,row=0,col=0;
                 for(i=0;i<3;i++)
                 for(j=0;j<3;j++)
                 if(array[i][j]>array[row][col])
                 {    row=i;col=j;}
                      printf("%d,%d",row,col);
            }
6、求出1000以内能被7或11整除,但不能同时被7和11整除的数,存放到数组xx中。请填空。
            main( )
            {
                int i,j=0;
                int xx[1000];
                for(i=1;i<1000;i++)
                     if(                                                                                                  )
                         xx[j++]=I;
                     printf("%d",j);
            }
7、下面程序的执行结果为:                    。
            main( )
            {    float x,y;
                 x=1/2;
                 y=2;
                 printf("%f\n",x+y);
            }

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