0
点赞
收藏
分享

微信扫一扫

2017年湖南省对口高考真题

Raow1 2023-07-26 阅读 45

一、选择题

1、

下列C语言标识符错误的是__________。

A.ABc               B.abc               C.A_bc              D.Ab.c

2、

分析以下程序,下列说法正确的是__________。

#include <stdio.h>
void main()
{
    int x=3,a=3,b=3;
    if(x=a+b)
        printf("* * * *");
    else
        printf("@ @ @ @");
}

A.输出:* * * *                         B.输出:@ @ @ @

C.不能输出编译,有语法错误    D.能通过编译,但不能连接

3、

若"int a;float b=12.2;",则执行"a=(int)b%3;"后,a的值是__________。

A.1                 B.0                 C.2.2               D.1.22

二、程序填空题

1、

从键盘上输入一个百分制成绩score,按下列原则输出其评分等级:

score≧90,等级为A;

80≦score<90,等级为B;

70≦score<80,等级为C;

60≦score<70,等级为D;

Score<60,等级为E

请补全下列代码:

#include <stdio.h>
void main()
{
    int data;
    _____ 1 _____ ;//定义grade字符变量
    printf("请输入成绩: ");
    scanf("%d",_____ 2 _____ );
    switch(data/10)
    {
        case 10:
        case 9:grade='A';break;
        case 8:grade='B';break;
        case 7:grade='C';break;
        case 6:grade='D';break;
        _____ 3 _____;
    }
    printf("评分等级为:%c",_____ 4 _____ );
}

三、写程序结果

1、

下列程序的运行结果是__________。

#include "stdio.h"
#include "string.h"
int main()
{
    char a[]= {'a','b','c','d','e','f','g','h','\n'};
    int x,y;
    x=sizeof(a);
    y=strlen(a);
    printf("%d,%d",x,y);
    return 0;
}

2、

下列程序的运行结果是__________。

#include "stdio.h"
void fun(int b[3])
{
    int j;
    for(j=0; j<3; j++)
    {
        b[j]=j;
    }
}
int main()
{
    int a[3]= {1,2,3},k;
    fun(a);
    for(k=0; k<3; k++)
    {
        printf("%d",a[k]);
    }
    return 0;
}

3、

下列程序的运行结果是__________。

#include "stdio.h"
int fun(int a,int b)
{
    return a+b;
}
int main()
{
    int x=2,y=3,z=4,r;
    r=fun(fun(x,y),z);
    printf("%d",r);
    return 0;
}

4、

下列程序的运行结果是__________。

#include "stdio.h"
int main()
{
    char a[]="abcdef",b[]="acdeea";
    char *p1,*p2;
    int i;
    p1=a;
    p2=b;
    for(i=0; i<6; i++)
    {
        if(*(p1+i)!=*(p2+i))
            printf("%c",*(p1+i));
    }
    return 0;
}

5、

下列程序的运行结果是__________。

#include "stdio.h"
void inv(int *p,int n)
{
    int *i,*j,m=(n-1)/2,t;
    j=p+n-1;
    for(i=p; i<p+m; i++,j--)
    {
        t=*i;
        *i=*j;
        *j=t;
    }
}
int main()
{
    int i;
    int a[]={3,5,7,0,6,2};
    inv(a,6);
    for(i=0; i<6; i++)
        printf("%d",a[i]);
    return 0;
}

四、程序填空

1、

函数countBit1用于统计某个字节中值为1的位的个数。

unsigned int countBit1(char byteData)
{
    int i;
    unsigned int num=0,tmpVal;
    for(i=0; i<8; i++)
    {
        tmpVal=_____ 1 _____;
        tmpVal &=0x01;
        if(tmpVal)
            _____ 2 _____;
    }
    return num;
}

2、

以下程序在main函数中调用reverse函数按逆序重新放置数组a中元素的值,reverse函数使用递归实现数组逆序。此程序运行后输出:54321

#include "stdio.h"
#define  N  5
void reverse(int *s,int i,int j)
{
    int t;
    if(i<j)
    {
        t=*(s+i);
        ______3______;
        *(s+j)=t;
        reverse(______4______);
    }
}
int main()
{
    int a[N]= {1,2,3,4,5};
    int i=0;
    reverse(______5______);
    for(i=0; i<N; i++)
        printf("%d",a[i]);
    return 0;
}

五、改错

1、

以下程序从键盘获得字符串输入,并将输入字符串追加写入C盘d去ta.txt文件中去。以下程序只允许修改两行。

int main()
{
    FILE *fp;
    char buf[100],*fileName="D://data.txt";
    gets(buf);
    if((fp=fopen(fileName,"w"))!=NULL);
    {
        puts(buf);
        fclose(fp);
    }
    return 0;
}

2、

函数endsWith(char *str,char *substr)用于判断字符串str是否以子字符串substr结尾,是返回整数1,否返回整数0。以下程序只允许修改三行。

int endsWith(char *str,char *substr)
{
    int sublen=0;
    while(str!='\0')
    {
        if(substr[sublen]!='\0')
        {
            sublen++;
        }
        str++;
    }
    int i=0;
    for(; i<sublen; i++)
    {
        char strCh=*str;
        char subCh=*--substr;
        if(strCh!=subCh)
        {
            return 0;
        }
    }
    return 1;
}

六、程序设计题

1、

编写程序用于从键盘逐个读取整数,并将整数按照升序插入链表,每插入一个数后将链表中的数据都输出一次,当输入整数0时结束插入。

#include "stdio.h"
#include "stdlib.h"
struct NumNode
{
    int data;
    struct NumNode *next;
};
struct NumNode *insertToList(struct NumNode *head,int fdata)
{
    struct NumNode *p,*q;
    struct NumNode *newNode=(struct NumNode *)malloc(sizeof(struct NumNode));
    newNode->data=fdata;
    newNode->next=NULL;
    p=head;
    q=head;
    if(head==NULL)
    {
        _____1_____;
        return head;
    }
    while(p!=NULL && fdata>p->data)
    {
        q=p;
        p=p->next;
    }
    if(p!=NULL)
    {
        if(head==p) 
        {
            ______2______;
        }
        else
            q->next=newNode;
        ______3______;
    }
    else 
    {
        ______4______;
    }
    return head;
}
void printList(struct NumNode *head)
{
    struct NumNode *p=head;
    while(p!=NULL)
    {
        printf("%d  ",p->data);
        p=p->next;
    }
    printf("\n");
}
int main()
{
    struct NumNode *head=NULL;
    int i;
    scanf("%d",&i);
    while(i!=0)
    {
        ______5______;
        printList(head);
        scanf("%d",&i);
    }
}

参考答案:

一、选择题

1—3    D、A、B

二、程序填空题

1、char grade           2、&data            3、default : grade='E'          4、grade

三、写程序结果

1、9,9          2、012          3、9            4、bcdf             5、267053

四、程序填空

1、byteData>>I                  2、num++

3、*(s+i)=*(s+j)                4、s,i+1,j-1                        5、a,i,N-1

五、改错

1、

L6  if((fp=fopen(fileName,"a"))!=NULL)

L8  fputs(buf,fp);

2、

L04     while(*str!='\0')//while(str!='\0')

L15     char strCh=*--str;//char strCh=*str;

L16     char subCh=substr[sublen-i-1];//char subCh=*--substr;

int main()

{

    int i;

    char a[]="abcdefeg",b[]="eg";

    i=endsWith(a,b);

    printf("%d",1);

    return 0;

}

六、程序设计题

1、head=newNode

2、head=newNode

3、newNode->next=p

4、q->next=newNode

5、head=insertToList(head,i)

举报

相关推荐

0 条评论