浙江省二级c语言上机考试真题介绍:浙江省二级c语言考试分为笔试和上机考试两块.取笔试和上机中分数较低的那个作为计算机二级的最终成绩,最后证书上按档次划分等级,其中60-79及格,80-89良好,90-100优秀。
笔试部分分两块,一块是24道选择题(六道程序题,每题中间有四个空,每空有四个选项供选择),浙江省的计算机笔试选择题不考概念性内容,所以大家不用费心,另一块是程序编写,手写两个完整程序,一道循环数组(结合),一道是函数或指针。
上机部分分两块,一块是计算机基本操作,即从access,ppt,excel,outlook,word,网页制作,文件夹操作中随机选择四道,另一块是编程,编程题可以打开编程软件c-free来做,编程中共五道题,一道改错,两道填空,最后两道是编写程序。
(一)程序改错:1,10个数求最大最小值该程序中“/***** N ***** /”的下一行中有错误,请改正(注意:不得加行、减行、加句、减句,否则后果自负)。
该程序功能:运行时输入10个数,然后分别输出其中的最大值、最小值。
#includevoid main(){ float x,max,min; int i;/******** 1 *******/for(i=0;i<=10;i++) {scanf("%f",&x);/******* 2 ********/if(i=1) { max=x;min=x;}if(x>max) max=x;if(x}printf("%f,%f\n",max,min);}•#include <stdio.h>•int main()•{ float x,max,min; int i;•/******** 1 *******/•for(i=1;i<=10;i++) {•scanf("%f",&x);•/******* 2 ********/•if(i==1) { max=x;min=x;}•if(x>max) max=x;•if(x<min) min=x;•}•printf("%f,%f\n",max,min);•}2,字符串反序连接下面程序中“***** N *****”的下一行中有错误,请改正(注意:不得加行、减行、加句、减句,否则后果自负)。
该程序功能:输入一个字符串,将组成字符串的所有字符先按顺序存放到字符串t中,再将字符串中的字符按逆序连接到字符串t 的后面。
例如:输入"ABCD",则字符串t为"ABCDDCBA"。
# include# includevoid fun(char *s,char *t){int i,sl;sl=strlen(s);for(i=0;it[i]=s[i];for(i=0;i/********1********/t[sl+i]=s[sl-i];/********2********/t[sl]="\0";}void main(){char s[100],t[100];scanf("%s",s);fun(s,t);printf("%s",t);}•#include <stdio.h>•#include <string.h>•void fun(char *s,char *t) •{•int i,sl;•sl=strlen(s);•for(i=0;i<sl;i++)•t[i]=s[i];•for(i=0;i<sl;i++)•t[sl+i]=s[sl-1-i];•/********2********/•t[2*sl]='\0';•}•void main()•{•char s[100],t[100];•scanf("%s",s);•fun(s,t);•printf("%s",t);•}3,求n的所有质数因子下面程序中“/***** N ***** /”的下一行中有错误,请改正(注意:不得加行、减行、加句、减句,否则后果自负)。
该程序功能:运行时输入n,输出n的所有质数因子(如n=13860,则输出2、2、3、3、5、7、11)。
#includevoid main(){ int n,i;scanf("%d",&n);/****** 1 ******/i=1;while(n>1)if(n%i==0) {printf("%d\t",i);n/=i;}else/******** 2 *******/n++;}•#include<stdio.h>•void main()•{ int n,i;•scanf("%d",&n);•/****** 1 ******/•i=2;•while(n>1)•if(n%i==0) {•printf("%8d",i);•n/=i;•}•else•/******** 2 *******/•i++;•}4,数字转字符下面程序中“/ ***** N ***** /”的下一行中有错误,请改正(注意:不得加行、减行、加句、减句,否则后果自负)。
该程序功能:用递归法将一个六位整数n转换成字符串,例如输入123456,应输出字符串"123456"。
#includevoid itoa(long i,char *s){if(i==0)return;/****** 1 ******/*s = '1'+i%10;itoa(i/10,s-1);}void main(){long n;char str[7]="";scanf("%ld",&n);/****** 2 ******/itoa(n,str+6);printf("%s",str);}•#include<stdio.h>•void itoa(long i,char *s) •{•if(i==0)•return;•/****** 1 ******/•*s ='0'+i%10;•itoa(i/10,s-1);•}•int main()•{•long n;•char str[7]="";•scanf("%ld",&n);•/****** 2 ******/•itoa(n,str+5);•printf("%s",str);•}6,删除非英文字母下面程序中“***** N *****”的下一行中有错误,请改正(注意:不得加行、减行、加句、减句,否则后果自负)。
该程序功能:输入一个字符串,将组成字符串的所有非英文字母的字符删除后输出。
例如:输入"abc123+xyz.5",应输出"abcxyz"。
#include#includevoid main(){char str[256];int i,j,k=0,n;gets(str);n=strlen(str);for(i=0;i/********1********/if (str[i] >='a' && str[i]<='z') {/********2********/str[k]=str[i]; i++;}str[k]='\0';printf("%s\n",str);}•#include <stdio.h>•#include <string.h>•void main()•{ char str[256];•int i,j,k=0,n;•gets(str);•n=strlen(str);•for(i=0;i<n;i++)•/********1********/•if ((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))•{•str[k]=str[i]; k++;•}•str[k]='\0';•printf("%s\n",str);•}7,距离坐标原点下面程序中“/***** N ***** /”的下一行中有错误,请改正(注意:不得加行、减行、加句、减句,否则后果自负)。
该程序功能:输入n,再输入n个点的平面坐标,然后输出那些距离坐标原点不超过5的点的坐标值。
#include "stdio.h"#include "math.h"#include "stdlib.h"void main(){int i,n;/***** 1 *****/struct axy { float x;float y; } a[n]; scanf("%d",&n);a=(float*) malloc(n*2*sizeof(float)); for(i=0;i/***** 2 *****/scanf("%f,%f",a[i].x,a[i].y);for(i=0;iif(sqrt(a[i].x*a[i].x+a[i].y*a[i].y)<=5) printf("%f,%f\n",a[i].x,a[i].y);}#include <stdio.h>#include <math.h>#include <stdlib.h>void main(){int i,n;/***** 1 *****/struct axy { float x,y; } a;scanf("%d",&n);a=(float*) malloc(n*2*sizeof(float));for(i=0;i<n;i++)/***** 2 *****/scanf("%f%f",a[i].x,a[i].y);for(i=0;i<n;i++)if(sqrt(a[i].x*a[i].x+a[i].y*a[i].y)<=5)printf("%f,%f\n",a[i].x,a[i].y);}**试题本身有错误,a=(struct axy *) malloc(n*2*sizeof(float));8,多项式值下面程序中“/***** N ***** /”的下一行中有错误,请改正(注意:不得加行、减行、加句、减句,否则后果自负)。