zoukankan      html  css  js  c++  java
  • 二级C笔试试题

    1994年4月
    一、选择题(1-30每小题1分,31-45每小题2分,共60分)
    下列各题 A),B),C),D)四个选项,只有一个选项是正确的,请将正确的选项在答题卡相应位置上涂黑。答在试卷上不得分。
    (1) 二进制数101110转换为等值的八进制数是 【1】 。
    【1】   A) 45 B) 56 C) 67 D) 78
    (2) CPU是由 【2】 组成的。【】
    【2】  A) 内存储器和控制器    B) 控制器和运算器
    C) 内存储器和运算器    D) 内存储器、控制器和运算器
    (3) DOS是为IBM PC系列微型计算机及其兼容机所配置的 【3】 磁盘操作系统。
    【3】 A)  多用户多任务   B) 单用户单任务    C) 分时 D) 分布式
    (4) 启动MS-DOS操作系统后, 【4】 已驻留内存。
    【4】 A) COMMAND.COM B) DISKCOPY.COM C) FORMAT.COM D) CCCC.EXE
    (5) 设驱动器B中软盘上的目录结构如下图所示。
         


         


         

    设当前目录为F2,则把A盘根目录下的PROG.BAS文件复制到B盘F3子目录中的命令是 【5】 。

            【5】 A) COPY PROG.BAS B: B) COPY A:PROG.BAS B:\

            C) COPY A:\PROG.BAS B:\F3 D) COPY A:PROG.BAS B:\F3\

            (6) 下面四组DOS命令中,意义完全相同的一组是 【6】 。

            【6】 A) COPY和DISKCOPY B) COMP和DISKCOMP

            C) DEL和RD D) RENAME和REN

            (7) 防止软盘感染病毒的有效方法是 【7】 。

            【7】 A) 不要把软盘和有毒软盘放在一起 B) 在写保护缺口上贴上胶条

            C) 保持机房清洁 D) 定期对软盘格式化

            (8) 双面高密度5英寸软磁盘的容量是 【8】 。

            【8】 A) 360KB B) 720KB C) 1.2MB D) 1.44MB

            (9) 在FOXBASE中,可以使用的两类变量是 【9】 。

            【9】 A) 内存变量和字段变量 B) 全局变量和局部变量

            C) 字段变量和简单变量 D) 内存变量和自动变量

            (10) 建立一个新子目录的DOS命令是 【10】 。

            【10】 A) CREATE B) RD C) MD D) CD

            (11) 在C语言中,如果下面的变量都是int类型,则输出的结果是 【11】 。

            sum=pad=5; pAd=sum + + ,pAd + + , + + pAd;

            printf("%d\n",pad);

            【11】 A) 7 B) 6 C) 5 D) 4

            (12) 以下程序的输出结果是 【12】 。

            # include <stdio.h>

            main()

            { int i=010 , j = 10;

            printf("%d,%d\n",+ +i , j - -); }

            【12】 A) 11,10 B) 9,10 C) 010,9 D) 10,9

            (13) 已知在ASCII代码中,字母A的序号为65,以下程序的输出的结果是 【13】 。

            # include <stdio.h>

            main()

            { char c1='A', c2='Y';

            printf("%d,%d\n",c1,c2); }

            【13】A) 因输出格式不合法,输出错误信息 B)65,90 C)A,Y D)65,89

            (14) 指针s所指字符串的长度为 【14】 。

            char *s="\\"Name\\Address\n";

            【14】 A) 19 B) 15 C) 18 D) 说明不合法

            (15) 设有说明int(*ptr)[m];其中的标识符ptr是 【15】 。

            【15】 A)M个指向整型变量的指针

            B)指向M个整型变量的函数指针

            C)一个指向具有M个整型元素的一维数组的指针

            D)具有M个指针元素的一维指针数组,每个元素都只能指向整型量

            (16) 语句while(!E);中的条件!E等价于 【16】 。

            【16】 A)E = = 0 B)E!=1 C)E!=0 D)~E

            (17) 以下程序的输出结果是 【17】 。

            # include <stdio.h>

            main()

            { printf("%d\n",NULL); }

            【17】 A) 不确定的(因变量无定义) B)0 C)-1 D)1

            (18) 以下函数调用语句中含有 【18】 个实参。

            func((exp1,exp2),(exp3,exp4,exp5));

            【18】 A) 1 B) 2 C) 4 D) 5

            (19) 设有以下语句:

            char a=3,b=6,c;

            c=a^b<<2;

            则c的二进制值是 【19】 。

            【19】 A) 00011011 B)00010100 C)00011100 D)00011000

            (20) 下面的程序中 【20】 有错误(每行程序前面的数字是行号)。

            1 #include <stdio.h>

            2 main()

            3 {

            4 float a[3]={0,0};

            5 int i;

            6 for(i=0;i<3;i + + ) scanf("%d",&a[i]);

            7 for(i=1;i<3;i + + ) a[0]=a[0]+a[i];

            8 printf("%f\n",a[0]);

            9 }

            【20】 A) 没有 B)第4行 C)第6行 D)第8行

            (21) 设有语句int a=3;则执行了语句a+=a-=a*a;后,变量a的值是 【21】 。

            【21】 A)3 B)0 C)9 D)-12

            (22) 以下的for循环 【22】 。

            for(x=0,y=0; (y!=123)&&(x<4); x + + );

            【22】A) 是无限循环 B)循环次数不定 C)执行4次 D)执行3次

            (23) 设有语句char a='\72';则变量a 【23】 。

            【23】A)包含1个字符 B)包含2个字符 C)包含3个字符 D)说明不合法

            (24) 以下程序的输出结果是 【24】 。

            # include <stdio.h>

            # include <math..h>

            main()

            { int a=1,b=4,c=2;

            float x=10..5 , y=4.0 , z;

            z=(a+b)/c+sqrt((double)y)*1.2/c+x;

            pritnf("%f\n",z); }

            【24】A) 14.000000 B) 015.400000 C) 13.700000 D) 14.900000

            (25) sizeof(double)是 【25】 。

            【25】 A)一种函数调用 B)一个双精度型表达式

            C)一个整型表达式 D)一个不合法的表达式

            (26) C语言中 【26】 。

            【26】 A)不能使用do-while语句构成的循环

            B)do-while语句构成的循环必须用break语句才能退出

            C)do-while语句构成的循环,当while语句中的表达式值为非零时结束循环

            D)do-while语句构成的循环,当while语句中的表达式值为零时结束循环

            (27) 以下程序的输出结果是 【27】 。

            # include <stdio.h>

            # include <string.h>

            main()

            { char str[12]={'s','t','r','i','n','g'};

            printf("%d\n",strlen(str)); }

            【27】 A) 6 B) 7 C) 11 D) 12

            (28) 以下程序的输出结果是 【28】 。

            # include <stdio.h>

            main()

            { int a=2,c=5;

            printf("a=%%d,b=%%d\n",a,c); }

            【28】A) a=%2,b=%5 B) a=2,b=5 C) a=%%d,b=%%d D) a=%d,b=%d

            (29) 以下程序的输出结果是 【29】 。

            # include<stdio.h>

            main()

            { int a ,b,d=241;

            a=d/100%9;

            b=(-1)&&(-1);

            printf("%d,%d\n",a,b); }

            【29】 A) 6,1 B) 2,1 C) 6,0 D) 2,0

            (30) 以下程序的输出结果是 【30】 。

            # include <stdio.h>

            main()

            { int i;

            for ( i=1;i<=5;i + + ) {if ( i%2 ) printf("*");

            else continue; printf("#");}

            printf("$\n"); }

            【30】 A) *#*#*#$ B) #*#*#*$ C) *#*#$ D) #*#*$

            (31) 以下for语句构成的循环执行了 【31】 次。

            # include <stdio.h>

            # define N 2

            # define M N+1

            # define NUM (M+1)*M/2

            main()

            { int i , n=0;

            for ( i=1;i<=NUM;i + + );

            {n + + ; printf("%d",n); }

            printf("\n"); }

            【31】 A) 5 B) 6 C) 8 D) 9

            (32) 设有以下语句,则 【32】 不是对a数组元素的正确引用,其中0≤i<10。

            int a[10]={0,1,2,3,4,5,6,7,8,9}, *p=a;

            【32】 A) a[p-a] B) *(&a[i]) C) p[i] D) *(*(a+i))

            (33) 有以下程序:

            # include <stdio.h>

            # define N 6

            main()

            { char c[N]; int i=0;

            for ( ;i<N ; c[i]=getchar () , i + + );

            for ( i=0 ; i<N ; putchar(c[i]) , i + + ); }

            输入以下三行,每行输入都是在第一列上 开始,<CR>代表一个回车符:

            a<CR>

            b<CR>

            cdef<CR>

            程序的输出结果是 【33】 。

            【33】 A) abcdef B) a C) a D) a

            b b b

            c cd cdef

            d

            e

            f

            (34) 以下程序调用findmax函数求数组中值最大的元素在数组中的下标,请选择填空。

            # include <stdio.h>

            findmax ( s , t , k )

            int *s , t , *k;

            { int p; for(p=0,*k=p;p<t;p + + )

            if ( s[p] > s[*k] )_________; }

            main()

            { int a[10] , i , k ;

            for ( i=0 ; i<10 ; i + + ) scanf("%d",&a[i]);

            findmax ( a,10,&k );

            printf ( "%d,%d\n" , k , a[k] ); }

            【34】 A) k=p B) *k=p-s C) k=p-s D) *k=p

            (35) 有以下程序:

            #include<stdio.h>

            union pw

            { int i; char ch[2]; } a;

            main()

            { a.ch[0]=13; a.ch[1]=0; printf("%d\n",a.i); }

            程序的输出结果是 【35】 。(注意: ch[0]在低字节,ch[1]在高字节。)

            【35】 A) 13 B) 14 C) 208 D) 209

            (36) 有以下程序:

            # include<stdio.h>

            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);

            case 4: putchar(c+2);break; } }

            printf("\n"); }

            从第一列开始输入以下数据,<CR>代表一个回车符。

            2743<CR>

            程序的输出结果是 【36】 。

            【36】 A) 668977 B) 668966 C) 6677877 D) 6688766

            (37) 以下程序的输出结果为 【37】 。

            main()

            { char *alpha[6]={"ABCD","IJKL","MNOP","QRST","UVWX"};

            char **p; int i;

            p=alpha;

            for(i=0;i<4;i + + ) printf("%s",p[i]); printf("\n");
            }

            【37】A) ABCDEFGHIJKL B) ABCD C) ABCDEFGHIJKLMNOP D) AEIM

            (38) 以下程序的输出结果是 【38】 。

            # include<stdio.h>

            # define FUDGE(y) 2.84+y

            # define PR(a) printf("%d",(int)(a))

            # define PRINT1(a) PR(a);putchar('\n')

            main()

            {int x=2; PRINT1(FUDGE(5)*x); }

            【38】 A) 11 B) 12 C) 13 D) 15

            (39) 以下程序的输出结果是 【39】 。

            # include<stdio.h>

            main()

            { int i=1,j=3;

            printf("%d",i + + );

            { int i=0; i+=j*2; printf("%d,%d",i,j); }

            printf("%d,%d\n",i,j); }

            【39】 A) 1,6,3,1,3 B) 1,6,3,2,3 C) 1,6,3,6,3 D) 1,7,3,2,3

            (40) 以下程序的输出结果是 【40】 。

            # include <stdio.h>

            main()

            { int k=4,m=1,p;

            p=func(k,m); printf("%d,",p); p=func(k,m); printf("%d\n",p);}

            func(a,b)

            int a,b;

            { static int m=0,i=2;

            i+=m+1; m=i+a+b; return(m); }

            【40】 A) 8,17 B) 8,16 C) 8,20 D) 8,8

            (41) 设有以下语句:

            char str[4][12]={"aaa","bbbb","ccccc","dddddd"},

            *strp[4];

            int i;

            for(i=0;i<4;i + + )strp[i]=str[i];

             【41】 不是对字符串的正确引用,其中0≤k<4。

            【41】 A) strp B) str[k] C) strp[k] D) *strp

            (42) 设有以下语句:

            char str1[]="string",str2[8],*str3,*str4="string";

            则 【42】 不是对库函数strcpy的正确调用,此库函数用业复制字符串。

            【42】 A) strcpy(str1,"HELLO1"); B) strcpy(str2,"HELLO2");
           

            C) strcpy(str3,"HELLO3"); D) strcpy(str4,"HELLO4");

            (43) C语言中形参的缺省存储类别是 【43】 。

            【43】A)自动(auto) B)静态(static) C)寄存器(register) D)外部(extern)

            (44) 设有以下语句:

            struct st {int n; struct st *next;};

            static struct st a[3]={5,&a[1],7,&a[2],9,'\0'},*p;

            p=&a[0];

            则表达式 【44】 的值是6。

            【44】 A)p + + ->n B) p->n + + C) (*p).n + + D) + + p->n

            (45) 以下四个程序中, 【45】 不能对两个整型变量的值进行交换。

            【45】A)# include <stdio.h>

            main()

            { int a=10,b=20; swap(&a,&b);

            printf("%d %d\n",a,b);

            }

            swap(p,q)

            int *p,*q;

            {

            int *t;

            t=(int )malloc(sizeof(int));

            t=p;*p=*q;*q=*t; }


         

    B) # include <stdio.h>

            main()

            {

            int a=10,b=20;

            swap(&a,&b);

            printf("%d %d\n",a,b);

            }

            swap(p,q)

            int p,q;

            {

            int *t;

            t=*p;*p=*q;*q=t;

            }


         

    C) # include <stdio.h>

            main()

            {

            int *a,*b;

            *a=10,*b=20;

            swap(a,b);

            printf("%d %d\n",*a,*b);

            }

            swap(p,q)

            int *p,*q;

            {

            int t;

            t=*p;*p=*q;*q=t;

            }


         

    D) # include<stdio.h>

            main()

            {

            int a=10,b=20;

            int x=&a,y=&b;

            swap(x,y);

            printf("%d %d\n",a,b);

            }

            swap(p,q)

            int *p,*q;

            {

            int t;

            t=*p;*p=*q;*q=t;

            }


         

    二、填空题(每空2分,共40分)

            请将每空的正确答案写在答题卡1-20序号后的横线上,答在试卷上不得分。

            (1) 结构化程序设计所规定的三种基本控制结构是 【1】 结构.选择结构和循环结构。

            (2) 在七位ASCII码中,除了表示数字、英文大小写字母外,还有 【2】 个其它符号。

            (3) 把B盘BAS子目录下第三个字符为A,且没有扩展名的全部文件拷贝到C盘ABC子目录下的命令是 【3】 。

            (4) 微机中ROM的中文意义是 【4】 存储器。

            (5) 启动MS-DOS系统后,能自动执行的批处理文件是 【5】 .BAT。

            (6) 设当前盘为C盘,删除B盘FOX子目录中扩展名为.TXT的所有文件的命令是 【6】 。

            (7) 十进制数53转换为十六进制数为 【7】 。

            (8) 数据库管理系统常见的数据模型有层次、网状和 【8】 三种。

            (9) 买来一张新盘后,在存入文件前,必须进行 【9】 处理。

            (10) 在微机中,字符的比较就是对它们的 【10】 码进行比较。

            (11) 以下C语言程序将磁盘中的一个文件复制到另一个文件中,两个文件名在命令行中给出。

            #include <stdio.h>

            main(argc,argv)

            int argc; char *argv[];

            { FILE *f1,*f2; char ch;

            if(argc< 【11】 )

            { printf("Parameters missing!\n"); exit(0); }

            if( ((f1=fopen(argv[1],"r")) = = NULL)||((f2=fopen(argv[2],"w"))
            = = NULL))

            { printf("Can not open file!\n"); exit(0);}

            while( 【12】 )fputc(fgetc(f1),f2);

            fclose(f1); fclose(f2); }

            (12) 以下程序中的trap函数是一个用梯形法求定积分的通用函数。梯形法求定积分的公式为:

            n-1 a-b

            s=((f(a)+f(b))/2+∑ f(a+i*h))*h , h=|----|

            i=1 n

            其中,n为积分小区间数。以下程序调用trap函数求定积分,被积函数是:

            f(x)=x*x+3*x+2,且n=1000,a=0,b=4。

            #include <stdio.h>

            3include <math.h>

            double trap(fun,a,b)

            double (*fun)(),a,b;

            { double t,h;

            int i,n=1000;

            t=0.5*((*fun)(a)+(*fun)(b)); h=fabs(a-b)/(double)(n);

            for(i=1;i<=n-1;i + + ) t=t+ 【13】 ;

            t=t*h; return(t); }

            double mypoly(x)

            double x;

            { return(x*x+3.0*x+2.0); }

            main()

            { double y,(*pf)(); pf= 【14】 ;

            y=trap(pf,0.0,4.0); printf("%f\n",y); }

            (13) 以下程序求a数组中的所有素数的和,函数isprime用来判断自变量是否为素数。素数是只能被1和本身整除且大于1的自然数。

            #include <stdio.h>

            main()

            { int i,a[10],*p=a,sum=0;

            printf("Enter 10 num:\n");

            for(i=0;i<10;i + + ) scanf("%d",&a[i]);

            for(i=0;i<10;i + + )

            if(isprime(*(p+ 【15】 )) = = 1){ printf("%d",*(a+i)); sum+=*(a+i);
            }

            printf("\nThe sum=%d\n",sum); }

            isprime(x)

            int x;

            { int i; for(i=2;i<=x/2;i + + )

            if(x%i = = 0) return (0); 【16】 ; }

            (14) 以下程序调用invert函数按逆序重新放置a数组中元素的值。a数组中的值在main函数中读入。

            #include <stdio.h>

            #define N 10

            invert(s,i,j)

            int *s,i,j;

            { int t; if(i<j){ t=*(s+i); *(s+j)=(s+j);*(s+j)=t; invert(s, 【17】 ,j-1);}}

            main()

            { int a[N],i;

            for(i=0;i<N;i + + ) scanf("%d",a+ 【18】 );

            invert(a,0,N-1);

            for(i=0;i<N;i + + ) printf("%d",a[i]);

            printf("\n"); }

            (15) 以下程序建立了一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为-1时,表示输入结束(链表头结点的data 域不放数据,表空的条件是ph->next
            = = NULL).

            #include<stdio.h>

            struct list { int data;struct list *next;};

            【19】 creatlist()

            { struct list *p,*q,*ph; int a;

            ph=(struct list *) malloc(sizeof(struct list));

            p=q=ph; printf("Input an integer number,enter -1 to end:\n");

            scanf("%d",&a):

            while(a!=-1)

            { p=(struct list *)malloc(sizeof(struct list));

            p->data=a; q->next=p; 【20】 =p; scanf("%d",&a); }

            p->next='\0'; return(ph); }

            main()

            { struct list *head; head=creatlist();}

  • 相关阅读:
    C# 语音识别
    Android—监听器
    android-Activity
    Android小案例——简单图片浏览器
    针对Android 模拟器启动慢的问题
    emulator-arm.exe 已停止工作、 emulator-x86 已停止工作
    android模拟器启动没有拨号功能
    安装好android的adt以后重启eclipse,但是没有创建AVD的图标
    android环境搭建——工欲善其事,必先利其器 2
    SQL 中常见的系统存储过程
  • 原文地址:https://www.cnblogs.com/dayouluo/p/119210.html
Copyright © 2011-2022 走看看