2009年湖南省对口高考真题中,哪一道题的解答过程最复杂?

2026-04-10 08:331阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计1535个文字,预计阅读时间需要7分钟。

2009年湖南省对口高考真题中,哪一道题的解答过程最复杂?

一、编写程序结果+1

二、程序输出结果+1

一、写程序结果

1、

#include <stdio.h> main() { struct stu { char name[10]; int age,sex; }; printf("%d",sizeof(struct stu)); }

运行结果是____________________。

2、

#include <stdio.h> main() { int x=68; printf("%c,%d",x,~x); }

运行结果是____________________。

3、

#include <stdio.h> #include <math.h> main() { double x=5.14; int a=(int)floor(x); int b=(int)pow(floor(x),3); printf("%d,%d",a,b); }

运行结果是____________________。

4、

#include <stdio.h> #include <math.h> main() { char **p,*t[]={"computer","phone","mp4"}; for(p=t+2; p>=t; p--) printf("%c ",*(*p+1)); }

运行结果是____________________。

5、

#include <stdio.h> void f(int arr[]) { int i=0; for(; arr[i]<=10; i+=2) printf("%d",arr[i]); } main() { int arr[]= {2,4,6,8,10,12}; f(arr+1); }

运行结果是____________________。


二、程序填空

以下程序的功能是:从3个红球、6个白球、5个蓝球中任意取出8个球,且其中至少有一个白球,输出所有可能的方案。

#include <stdio.h> main() { int i,j,k; printf("\nRde White Blue"); for(i=0; i<=3; i++) for( __________ 1 __________ ; j<=6; j++) { k= __________ 2 __________ ; if( __________ 3 __________ ) printf("%d,%d,%d\n",i,j,k); } }


以下程序的功能是:求100以内最大的一对孪生素数之和,孪生素数是指两个素数之差为2。

#include <stdio.h> #include <math.h> int isPrime(int i) { int j,r=0,k=sqrt(i); for(j=2; j<=k; j++) { if(i%j==0) break; } if(j>k) { r=1; } __________ 4 __________ ; } main() { int i,sum=0; for (i=100; i>=5;i--) { if( __________ 5 __________ ) { sum=i+i-2; __________ 6 __________ ; } } printf("%d\n",sum); }


三、改错


以下程序的功能是:从一个整数队列中找出值最大的数,若有多个则取最先得到的那一个。程序中有2处错误,请标记并改正。

#include <stdio.h> int *findMax(int a[],int n) { int i,j,max; for(i=1,j=0,max=a[0]; i<n; i++) { if(a[i]>max) { j=i; max=a[i]; } } return *(a+j); } main() { int i,a[50]; printf("enter array:"); for(i=0; i<50; i++) scanf("%d",&a[i]); printf("%d",findMax(a,50)); }


以下程序的功能是:读入一个字符串(长度<80),将该字符串中的所有字符按ASCII码降序排序后输出。在程序中有2处错误,请标记并改正。

#include <stdio.h> #include <string.h> void fun(char t[]) { char c; int i,j; for(i=0; i<strlen(t)-1; i++) for(j=i+1; j<strlen(t)-1; j++) if(t[i]<t[j]) { c=[j]; t[j]=t[i++]; t[i]=c; } } main() { char s[81]; printf("\nPlease enter a character string :"); gets(s); printf("\n\nBefore sorting :\n %s",s); fun(s); printf("\nAfter sorting decendingly:\n%s",s); }


四、程序设计题


某学校操场上有一些学生,老师想知道有多少人,便让学生排队报数:按从1到5报,最后一名学生报的数为1,按从1到6报,最后一名学生报的数为5;按从1到7报,最后一名学生报的数为4,最后再按从1到11报,最后一名学生报的数为10。编写程序求操场上共有多少学生。

2009年湖南省对口高考真题中,哪一道题的解答过程最复杂?


五、程序方向


(一)、程序填空

以下程序的功能是:输入某公司50名职员的工号、姓名和地址并存入名为“company.txt”的磁盘文件。请将正确的内容填入答题卡相应位置中,使程序完整。

#include "stdio.h" #include "stdlib.h" struct Employee { int EmpId; char EmpName[10]; char EmpAdd[30]; } Emp[50]; void save() { __________ 1 __________ int i; if((fp=fopen("company.txt","wb"))==NULL) { printf("cannnot open file\n"); return; } for(i=0; i<1; i++) { if(fwrite( __________ 2 __________ )!=1) printf("file write error\n"); } } main() { int i; for(i=0; i<1; i++) scanf("%d,%s,%s",__________ 3 __________ ,Emp[i].EmpName,Emp[i].EmpAdd); save(); }


(二)、程序设计

将自然数1~100按顺时针围成一圈,首先取出1,然后按顺时针方向以步长30取数,(已取出的数不再参加计数),直至所有的数取完为止。编程求最后一个取出的数是多少?



参考答案:

一、写程序结果

1、 TC 14 VC 20 2、 D,-69 3、 5,125

4、 p h o 5、 48

二、程序填空

1、 j=1 2、 k=8-i-j 3、 k<=5&&k>=0

4、 return r 5、 isPrime(i) && isPrime(i-2)

6、 break

注:对于第二题,在Microsoft Visual C++ 2010 Express中运行时,sqrt中的参数要强制转换为float型。

三、改错

1、 L2 int findMax(int a[],int n)//int *findMax(int a[],int n)

2、 L8 max=a[j]; }//max=a[i]; }

3、 L8 for(j=i+1; j<strlen(t); j++)//for(j=i+1; j<strlen(t)-1; j++)

4、 L12 t[j]=t[i];//t[j]=t[i++];

应该认为L11没有错,是笔误 c=t[j];//c=[j];

注:调试时可将第1题输入改为:a[i]=rand()%100;//scanf("%d",&a[i]);

四、程序设计题

1、参考代码

#include <stdio.h> main() { int i=10; while(1) { if(i%5==1 && i%6==5 && i%7==4 && i%11==10) { printf("操场上有%d个学生:",i); break; } else i++; } }

五、程序方向

(一)、程序填空

1、 FILE *fp; 2、 &Emp[i],sizeof(struct Employee),1,fp

3、 &Emp[i].EmpId

(二)、程序设计

参考代码

#include <stdio.h> main() { int x[101]={0}; int i=101,k=30,n=0; while(1) { if(i==101) i=1; if(k==30) { x[i]=1; k=0; n++; //printf("\n %d",i); } i++; if(x[i]==0) k++; if(n==99)break; } for(i=1;i<=100;i++) if(x[i]==0) printf("this is %d",i); }

本文共计1535个文字,预计阅读时间需要7分钟。

2009年湖南省对口高考真题中,哪一道题的解答过程最复杂?

一、编写程序结果+1

二、程序输出结果+1

一、写程序结果

1、

#include <stdio.h> main() { struct stu { char name[10]; int age,sex; }; printf("%d",sizeof(struct stu)); }

运行结果是____________________。

2、

#include <stdio.h> main() { int x=68; printf("%c,%d",x,~x); }

运行结果是____________________。

3、

#include <stdio.h> #include <math.h> main() { double x=5.14; int a=(int)floor(x); int b=(int)pow(floor(x),3); printf("%d,%d",a,b); }

运行结果是____________________。

4、

#include <stdio.h> #include <math.h> main() { char **p,*t[]={"computer","phone","mp4"}; for(p=t+2; p>=t; p--) printf("%c ",*(*p+1)); }

运行结果是____________________。

5、

#include <stdio.h> void f(int arr[]) { int i=0; for(; arr[i]<=10; i+=2) printf("%d",arr[i]); } main() { int arr[]= {2,4,6,8,10,12}; f(arr+1); }

运行结果是____________________。


二、程序填空

以下程序的功能是:从3个红球、6个白球、5个蓝球中任意取出8个球,且其中至少有一个白球,输出所有可能的方案。

#include <stdio.h> main() { int i,j,k; printf("\nRde White Blue"); for(i=0; i<=3; i++) for( __________ 1 __________ ; j<=6; j++) { k= __________ 2 __________ ; if( __________ 3 __________ ) printf("%d,%d,%d\n",i,j,k); } }


以下程序的功能是:求100以内最大的一对孪生素数之和,孪生素数是指两个素数之差为2。

#include <stdio.h> #include <math.h> int isPrime(int i) { int j,r=0,k=sqrt(i); for(j=2; j<=k; j++) { if(i%j==0) break; } if(j>k) { r=1; } __________ 4 __________ ; } main() { int i,sum=0; for (i=100; i>=5;i--) { if( __________ 5 __________ ) { sum=i+i-2; __________ 6 __________ ; } } printf("%d\n",sum); }


三、改错


以下程序的功能是:从一个整数队列中找出值最大的数,若有多个则取最先得到的那一个。程序中有2处错误,请标记并改正。

#include <stdio.h> int *findMax(int a[],int n) { int i,j,max; for(i=1,j=0,max=a[0]; i<n; i++) { if(a[i]>max) { j=i; max=a[i]; } } return *(a+j); } main() { int i,a[50]; printf("enter array:"); for(i=0; i<50; i++) scanf("%d",&a[i]); printf("%d",findMax(a,50)); }


以下程序的功能是:读入一个字符串(长度<80),将该字符串中的所有字符按ASCII码降序排序后输出。在程序中有2处错误,请标记并改正。

#include <stdio.h> #include <string.h> void fun(char t[]) { char c; int i,j; for(i=0; i<strlen(t)-1; i++) for(j=i+1; j<strlen(t)-1; j++) if(t[i]<t[j]) { c=[j]; t[j]=t[i++]; t[i]=c; } } main() { char s[81]; printf("\nPlease enter a character string :"); gets(s); printf("\n\nBefore sorting :\n %s",s); fun(s); printf("\nAfter sorting decendingly:\n%s",s); }


四、程序设计题


某学校操场上有一些学生,老师想知道有多少人,便让学生排队报数:按从1到5报,最后一名学生报的数为1,按从1到6报,最后一名学生报的数为5;按从1到7报,最后一名学生报的数为4,最后再按从1到11报,最后一名学生报的数为10。编写程序求操场上共有多少学生。

2009年湖南省对口高考真题中,哪一道题的解答过程最复杂?


五、程序方向


(一)、程序填空

以下程序的功能是:输入某公司50名职员的工号、姓名和地址并存入名为“company.txt”的磁盘文件。请将正确的内容填入答题卡相应位置中,使程序完整。

#include "stdio.h" #include "stdlib.h" struct Employee { int EmpId; char EmpName[10]; char EmpAdd[30]; } Emp[50]; void save() { __________ 1 __________ int i; if((fp=fopen("company.txt","wb"))==NULL) { printf("cannnot open file\n"); return; } for(i=0; i<1; i++) { if(fwrite( __________ 2 __________ )!=1) printf("file write error\n"); } } main() { int i; for(i=0; i<1; i++) scanf("%d,%s,%s",__________ 3 __________ ,Emp[i].EmpName,Emp[i].EmpAdd); save(); }


(二)、程序设计

将自然数1~100按顺时针围成一圈,首先取出1,然后按顺时针方向以步长30取数,(已取出的数不再参加计数),直至所有的数取完为止。编程求最后一个取出的数是多少?



参考答案:

一、写程序结果

1、 TC 14 VC 20 2、 D,-69 3、 5,125

4、 p h o 5、 48

二、程序填空

1、 j=1 2、 k=8-i-j 3、 k<=5&&k>=0

4、 return r 5、 isPrime(i) && isPrime(i-2)

6、 break

注:对于第二题,在Microsoft Visual C++ 2010 Express中运行时,sqrt中的参数要强制转换为float型。

三、改错

1、 L2 int findMax(int a[],int n)//int *findMax(int a[],int n)

2、 L8 max=a[j]; }//max=a[i]; }

3、 L8 for(j=i+1; j<strlen(t); j++)//for(j=i+1; j<strlen(t)-1; j++)

4、 L12 t[j]=t[i];//t[j]=t[i++];

应该认为L11没有错,是笔误 c=t[j];//c=[j];

注:调试时可将第1题输入改为:a[i]=rand()%100;//scanf("%d",&a[i]);

四、程序设计题

1、参考代码

#include <stdio.h> main() { int i=10; while(1) { if(i%5==1 && i%6==5 && i%7==4 && i%11==10) { printf("操场上有%d个学生:",i); break; } else i++; } }

五、程序方向

(一)、程序填空

1、 FILE *fp; 2、 &Emp[i],sizeof(struct Employee),1,fp

3、 &Emp[i].EmpId

(二)、程序设计

参考代码

#include <stdio.h> main() { int x[101]={0}; int i=101,k=30,n=0; while(1) { if(i==101) i=1; if(k==30) { x[i]=1; k=0; n++; //printf("\n %d",i); } i++; if(x[i]==0) k++; if(n==99)break; } for(i=1;i<=100;i++) if(x[i]==0) printf("this is %d",i); }