第一篇:2013年普通专升本考试编程题总结
2013年普通专升本考试编程题总结
一、数学表达式
1、编写程序,其功能是:计算并输出下列多项式的值: , 将结果存到外存root.txt中。
2、编写程序,其功能是:计算并输出下列多项式的值:
3、编写程序,其功能是:计算并输出下列多项式的值:,并输出结果。例如,若n=20,则S=6.506583。
4、编写程序,计算表达式: 直到。例如x=2.5,则函数值为:12.182494。
5、找出100~999之间的所有“水仙花数”(穷举法、统计)
6、从键盘输入10个数,然后找出其中的最大值和最小值。(找最大数、最小数)
7、任意输入n个数,按由小到大的顺序排列并显示输出。(排序算法--选择法排序)
8、求5的阶乘值(5!=?)
9、计算 t=1!+2!+„„+10!(即求阶乘之和)。
计算 t=1!+2!+„„+10!即求阶乘之和(双循环)。
10、多项式S=1+2+22+23+„„+232,请设计一个程序,求S的值。
二、矩阵的处理
编写程序,完成的功能是:
(1)实现B=A+A’,即把矩阵A加上A的转置,存放在矩阵B中。例如用户输入矩阵,其转置矩阵为,程序输出。
(2)求矩阵A对角线元素之和。
三、字符串的处理
1、编写一个程序,它的功能是:将ss字符串中所有下标为奇数位置上的字母转换为大写(若该位置上不是字母,则不转换)。例如,若输入“abc4EFg”,则应输出“aBc4EFg”。
2、程序的功能是:将s所指字符串中ASCII值为偶数的字符删除,串中剩余字符形成一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为:“ABCDEFG12345”,其中字符B的ASCII码值为偶数、„、字符2的ASCII码值为偶数、„、都应当删除,其它依此类推。最后t所指的数组中的内容应是:“ACEG135”。
3、编写程序,实现将s所指字符串中的所有数字字符移到所有非数字字符之后,并保持数字字符串和非数字字符串原有的先后次序。例如,原字符串为:def35adh3kjsdf7,执行结果为:defadhkjsdf35374、假定输入的字符串中只包含字母和*号。请编写程序,它的功能是:使字符串中尾部的*号不得多于n个;若多于n个,则删除多于的*号;若少于或等于n个,则什么也不做,字符串中间和前面的*号不删除。
5、(对字符串排序处理)有5个英文单词,分别为:Word,Excel,Powerpoint,Type,Angle,要求设计出如下程序:
(1)在键盘上输入数N(本例输入5),把英文单词放入名为X大小为N的数组中
(2)显示出X数组中的英文单词
(3)对数组中的英文单词从小到大排序
(4)显示出排序后X数组中英文单词
三、数据的处理
1、程序的功能是:将两个两位数的正整数a.b合并形成一个整数放在c中。合并的方式是:将a数的十位和个位数依次放在c数的个位和百位上,b数的十位和个位数依次放在c数的千位和十位上。
例如,当a=45,b=12时,执行该程序后,c=1524。
2、请编写程序,它的功能是:求出1到1000之间能被7或11整除,但不能同时被7和11整除的所有整数并将它们放在a所指的数组中,通过n返回这些数的个数。
3、编写程序,求Fibonacci数列中大于t的最小的一个数。其中Fibonacci数列F(n)的定义为:
F(0)=0,F(1)=1,F(n)=F(n-1)+F(n-2)。例如:当t=1000时,函数值为:1597。
4、编写程序,实现根据输入的三个边长(整型值),判断能否构成三角形;构成的是等边三角形,还是等腰三角形。若能构成等边三角形函数返回3,若能构成等腰三角形函数返回2,若能构成一般三角形函数返回1,若不能构成三角形函数返回0。
5、编写程序,实现计算并输出3到n之间(含3和n)所有素数的平方根之和。例如,n=100,则输出s=148.874270,注意:要求n的值大于2但不大于100。
6、编写程序,它的功能是:利用以下所示的简单迭代方法求方程:cos(x)-x=0的一个实根。迭代表达式为:xn+1=cos(xn)
(1)取x1初值为0.0;
(2)x0=x1,把x1的值赋给x0;
(3)x1=cos(x0),求出一个新的x1;
(4)若x0-xl的绝对值小于0.000001,执行步骤(5),否则执行步骤(2);
(5)所求x1就是方程cos(x)-x=0的一个实根,作为函数值返回。
1.有3个数a,b,c,要求按大小顺序把它们打印出来。
2.求1+2+3+„„„+100。
3.判断一个数n 能否同时被3和5整除。
4.将100~200之间的素数打印出来
5.求两个数m和n的最大公约数。
6.求方程式ax2+bx+c=0的根。分别考虑:(1)有两个不等的实根:(2)有两个相等的实根。
8.有一个函数:
x(x<1)
y=2x-1(1≤x<10)
3x-11(x≥10)
写一个程序,输入x,输出y值。
9.给出一个百分制成绩,要求输出成绩等级‘A’,‘B’,‘C’,‘D’,‘E’。90分以上为‘A’,80-90分为‘B’,70~79分为‘C’,60~69分为‘D’,60分以下为‘E’。
10.求Fibonacci数列40个数。这个数列有如下特点:第1,2两个数为1,1。
从第3个数开始该数是其前面两个数之和。即:F1=1(n=1)F2=1(n=2)这是一个有趣的古典数学问题:有一对兔子,从出生后第3 个月起每个月都生一对兔子。小兔子长到第3个月后每个月又生
Fn =Fn-1+Fn-2(n≥3)一对兔子。假设所有兔子都不死,问每个月的兔子总数为多少?
11.求100~200间的全部素数。
12.求1!+ 2!+ 3!+ 4!+ „ +20!。
13.(1+2+„+100)+(12+22+„+502)+(1+1/2+„+1/10)。
14.打印出所有的“水仙花数”,所谓“水仙花数”是指一个3位数,其各位数字立方和等于该数本身。例如,153是一水仙花数,因为153=13+53+33。
15.有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13,„,求出这个数列的前20项之和。
16.猴子吃桃问题。猴子第一天摘下若干个桃子,当即吃了一半,还不过瘾,又多吃了一个,第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第十天早上想再吃时,就只剩下一个桃子了。求第一天共摘多少桃子?
17.用二分法求下面方程在(-10,10)之间的根。
2x3-4x2+3x-6=0
19.用起泡法对10个数排序(由大到小)。
20.将一个二维数组行和列元素互换,存到另一个二维数组中。
例如:a(2,3)=(1 2 34 5 6)
B(3,2)=(1 42 53 6)
21.有一个3×4的矩阵,要求编程序求出其中值最大的那个元素的值,以及其所在的行号和列号。
22.用筛法求100之内的素数。
23.用选择法对10个整数排序。
24.已有一个排好序的数组,今输入一个数,要求按原来排序的规律将它插入数
组中。
25.将一个数组按逆序重新排放。例如,原来顺序为8,6,5,4,1。要求改为1,4,5,6,8。
第二篇:编程题总结
C作业汇总
1.short a,b=32767;/*short类型在内存中占2B*/ a=b+1;问:a的值是多少?并分析原因。
2.有一4位数整数,假设用abcd表示,请把这个4位数的每个数位用表达式表示出来。3.从键盘输入圆的半径r,计算并输出圆的面积s(要求:半径r定义为float型;圆周率定义为符号常量;面积s保留2位小数)#define PI 3.14159 #include
4.输入m>=3的正整数,判断m是否素数。画出算法流程图及NS图
5.有一函数:
x1 x y2x1 1x10
3x-11 x10 写一段程序,输入x,输出y值。
要求x,y声明为float类型,y保留2位小数。#include
if(x<1)
y=x;else
if(x<10)
y=2*x-1;
else
y=3*x-11;
}
printf(“y=%.2fn”,y);
x3x5x7x9,6.课后习题4.17(P159)利用泰勒级数sinxx计算sinx的3!5!7!9!值。要求最后一项的绝对值小于10,并统计出此时累加了多少项。#include
/*记录每个项数*/ int n=1,count=0;/*count记录累加了多少项*/
printf(“请输入x值(弧度):n”);scanf(“%f”,&x);
term=x/n;while(fabs(term)>1e-5)
/* while循环*/ {
sinx+=term;
count++;
n+=2;
term=-term*x*x/((n-1)*n);}
/* do
/*do while循环*/ {
sinx+=term;
count++;
n+=2;
term=-term*x*x/((n-1)*n);}while(fabs(term)>1e-5);
*/
printf(“sin(%.2f)=%.4fn”,x,sinx);printf(“一共累加了:%d项。n”,count);}
7.用牛顿迭代法求下面方程在1.5附近的根:
2x4x3x60 325
牛顿迭代公式:
x1x0f(x0)f(x0)
#include
/*y1记录f(x0),y2记录f(x0)的导数*/
do {
x0=x1;
y1=2*x0*x0*x0-4*x0*x0+3*x0-6;
y2=6*x0*x0-8*x0+3;
x1=x0-y1/y2;}while(fabs(x1-x0)>1e-5);
printf(“the root is:%.2fn”,x1);}
8.写一函数,输入一个16进制整数,输出相应的10进制数。例:从键盘输入2a,输出结果是42。
要求:若输入数据不合法,则输出提示信息。如输入了35g,输出“您输入的16进制数不合法!”。
#include
printf(“请输入一个16进制数字:n”);
while((c=getchar())!='n'){
if(c>='0' && c<='9')
sum=sum*16+c-'0';
else
if(c>='a' && c<='f')
sum=sum*16+c-87;
else
if(c>='A' && c<='F')
sum=sum*16+c-55;
else
{
printf(“您输入的16进制不合法.n”);
exit(0);
} }
printf(“相应的10进制数是:%dn”,sum);} 方法2:用字符串处理的方式 #include
printf(“请输入一个16进制数字:n”);gets(str);
for(i=0;str[i];i++){
if(str[i]>='0' && str[i]<='9')
sum=sum*16+str[i]-'0';
else
if(str[i]>='a' && str[i]<='f')
sum=sum*16+str[i]-87;
else
if(str[i]>='A' && str[i]<='F')
sum=sum*16+str[i]-55;
else
{
printf(“您输入的16进制不合法.n”);
exit(0);
} }
printf(“相应的10进制数是:%dn”,sum);} 方法3:用字符数组及指针处理的方式 #include
{ char str[20],*p=str;int sum=0;
printf(“请输入一个16进制数字:n”);gets(p);
while(*p){
if(*p>='0' && *p<='9')
sum=sum*16+*p-'0';
else
if(*p>='a' && *p<='f')
sum=sum*16+*p-87;
else
if(*p>='A' && *p<='F')
sum=sum*16+*p-55;
else
{
printf(“您输入的16进制不合法.n”);
exit(0);
}
p++;}
printf(“相应的10进制数是:%dn”,sum);} 9.编写一个小函数,其功能是计算两个整数的平均值,该函数要在主函数中调用。
#include
avg=average(x,y);
printf(“%d,%d的平均值是:%.2fn”,x,y,avg);}
float average(int x,int y)
{ return(x+y)/2.0;}
10.有N(N用宏定义为符号常量)个元素的一维整型数组,该数组中各元素值从键盘随机输入。然后,将这个整型数组中的值逆序存放。例如,原来5个元素的顺序为8、1、4、6、5,逆序之后各元素的值是5、6、4、1、8 #define N 5 #include
printf(“输入%d个整数,用空格或回车分隔:n”,N);for(i=0;i scanf(“%d”,&a[i]); printf(“数组原来的值是:n”);for(i=0;i printf(“%dt”,a[i]); for(i=0;i t=a[i]; a[i]=a[N-1-i]; a[N-1-i]=t;} printf(“n逆序之后数组的值是:n”);for(i=0;i printf(“%dt”,a[i]); printf(“n”);} 11.有N(N用宏定义为符号常量)个元素的一维整型数组,该数组中各元素值从键盘随机输入。然后,对该数组元素进行由小到大排序(要求,该功能用函数实现),输出数组中各元素值。最后,从键盘随机输入一个整数,并把该整数插入上述数组中(该功能用函数实现),使得插入该整数后的数组仍然有序,输出数组中各元素的值。#define N 5 #include int i,x;void sort(int array[],int n);void insert(int array[],int n,int x); printf(“输入%d个整数,用空格或回车分隔:n”,N);for(i=0;i scanf(“%d”,&a[i]); sort(a,N); /*调用sort对数组进行排序*/ printf(“n升序排序之后数组的值是:n”);for(i=0;i printf(“%d ”,a[i]); printf(“n输入一个x值插入到数组中:n”);scanf(“%d”,&x); insert(a,N,x); printf(“n插入%d之后数组的值是:n”,x);for(i=0;i printf(“%d ”,a[i]); printf(“n”);} void sort(int array[],int n)/*用选择法对数组array升序排序*/ { int i,j,t,min; for(i=0;i min=i; for(j=i+1;j if(array[j] min=j; if(min!=i) { t=array[i]; array[i]=array[min]; array[min]=t; } } } void insert(int array[],int n,int x){ int i,pos; for(i=0;i pos=i; for(i=n-1;i>=pos;i--) array[i+1]=array[i]; array[pos]=x;} 12.有一整型数组,N(N用宏定义为符号常量)个元素,该数组中各元素值从键盘随机输入。从键盘随机输入一个整数x,删除该数组中值与x相同的所有元素(该功能用函数实现),输出数组中各元素的值。#define N 5 #include printf(“输入%d个整数,用空格或回车分隔:n”,N);for(i=0;i scanf(“%d”,&a[i]); printf(“数组原来的值是:n”);for(i=0;i printf(“%dt”,a[i]); printf(“n请输入要删除的值x:n”);scanf(“%d”,&x); n=delet(a,N,x); /*n值是删除与x相同的元素后,数组剩余元素的个数。*/ printf(“删除%d之后数组的值是:n”,x);for(i=0;i printf(“%d ”,a[i]); printf(“n”); } int delet(int a[],int n,int x){ int i,j; for(i=0,j=0;i if(a[i]!=x) a[j++]=a[i]; return j;} 13.从键盘随机输入一字符串,将所有ASCII值为偶数的字符输出。例如:输入abc123,输出结果是b2(因为b的ASCII值是98,2的ASCII值是50,其他字符的ASCII值都是奇数) #include printf(“输入字符串:n”);gets(str); printf(“ASCII码是偶数的字符有:”);for(i=0;str[i];i++) if(str[i]%2==0)putchar(str[i]); printf(“n”);} 14.从键盘输入两个字符串s1,s2,把s2连接到s1的末尾。不能用strcat函数 #include printf(“输入两个字符串,输入回车键结束:n”);gets(str1);gets(str2); mystrcat(str1,str2); printf(“连接在一起的字符串是:n”);puts(str1); } void mystrcat(char *p1,char *p2){ while(*p1)p1++;while(*p2) *p1++=*p2++;*p1=' ';} 15.从键盘输入一个字符串,把其中最长的单词输出。单词定义为连续的一串英文字母。如输入I am a student.输出结果为student #include { char str[80];int i,start,len=0,lenthest=0,lenstart=0;int word=0; printf(“input a string:n”);gets(str); for(i=0;str[i];i++){ if(str[i]>='a' && str[i]<='z' || str[i]>='A'&&str[i]<='Z') if(!word) { word=1; start=i; } else { len++; } else if(word) { word=0; } } if(len>lenthest){ lenthest=len;lenstart=start;} len=0; printf(“the lenthest word is:n”);for(i=lenstart;i<=lenstart+lenthest;i++) putchar(str[i]); printf(“n”);} 16.有一整型数组,N(N用宏定义为符号常量)个元素,该数组中各元素值从键盘随机输入。编写函数calculate,计算出所有元素的最大值、最小值、平均值,结果在主函数中输出。#define N 5 #include printf(“输入%d个整数,用空格或回车分隔:n”,N);for(i=0;i scanf(“%d”,&a[i]); calculate(a,&max,&min,&avg); printf(“数组中所有元素的最大值、最小值、平均值分别是:n”);printf(“最大值max=%d,n”,max);if(word)if(len>lenthest){ lenthest=len; lenstart=start;} printf(“最小值min=%d,n”,min);printf(“平均值avg=%.2f,n”,avg); } void calculate(int a[],int *pmax,int *pmin,float *pavg){ int i;int sum; *pmax=*pmin=sum=a[0]; for(i=1;i if(a[i]>*pmax) *pmax=a[i]; if(a[i]<*pmin) *pmin=a[i]; sum=sum+a[i];} *pavg=(float)sum/N;} 大家必须掌握每种类型的1-3题。 题号考点要求 48、将两个两位数的整数合并成一个整数 65、两个正整数合并成一个整数 71、两个正整数合并成一个整数 77、两个正整数合并成一个整数 81、两个正整数合并成一个整数 84、两个正整数合并成一个整数 87、两个正整数合并成一个整数 91、两个正整数合并成一个整数 8、s=1+1/(1+2)+1/(1+2+3)+...+1/(1+2+3+.....+n) 9、p=m!/(n!*(m-n)!) 26、连加 68、s=1+1/1!+1/2!+1/3!+........70、s=1/(1*2)+1/(2*3)+...+1/(n*(n+1)) 76、s=1+0.5*x+(0.5*(0.5-1)*x*x/2!+......86、连加 90、连加 92、连加 93、连加 97、连加 100、连加 (2、) 类似素数或者闰年算法 2、求出1到1000之间能被7或11整除、但不能同时被7和11整除的所有整数,并将他们放在a所指的数组中,通过n返回这些数的个数。 58、求n以内同时能被3与7整除的所有自然数之和的平方根s3、求出能整除x且不是偶数的各整数,并按从小到大的顺序放在pp所指的数组中,这些除数的个数通过形参n返回。 27、求出1到m之间能被7或11整除的整数,放在数组中,通过n返回这些数的个数 63、求n的所有因子(不包括1与自身) 98、计算n以内能被5或9整除的所有自然数的倒数之和 15、w是大于10的无符号整数,若w是n(n>=2)位的整数,则函数求出w的后n-1位的数作为函数值返回。 24、将数字字符串转化为一个整数 16、对变量中的值保留两位小数,对第三位四舍五入 (3、) 1、一维数组中,将低于平均分的人数作为函数值返回,低于平均分的分数放在below所指的数组中。 82、计算一维数组中n门课程的平均分 96、一维数组中每相邻元素之平均值的平方根之和 28、找出一维数组中最大的值和它所在的下标,两者通过形参返回 7、求出数组的最大元素在数组中下标并存放在k所指的存贮单元中。 43、从num个字符串中找出最长的一个字符串,并通过形参指针传回 39、移动数组中的内容,前p个数移动到数组后面 40、移动数组中的内容,前m个字符移动到后面 5、将大于整数m且紧靠m的k个素数存入xx所指的数组中。 20、求出小于变量m的所有素数并放在一个数组中 51、将大于1小于m的非素数存入xx所指数组中,个数通过形参返回 99、计算3到n之间所有素数的平方根之和 29、将字符串中下标为奇数位置上的字母转化为大写 47、字符串中所有下标为奇数的字母转为大写 31、将字符串中除了下标为偶数、同时ASCII码也为偶数的字符外,其余的全都删除;串中剩余字符放在t字符串中 32、除了下标为奇数、同时ASCII码也为奇数的字符外,其余的全都删除;串中剩余字符放在t字符串中 49、将字符串中下标为偶数且ASCII码为奇数的字符删除 19、从字符串中删除指定字符 64、将字符串中ASCII值为奇数的字符删除,剩余字符放在t所指字符串中 72、将字符串中下标为偶数的字符删除 78、字符串中ASCII为偶数的字符删除 35、删除字符串中所有空格 6、删除一个字符串中指定下标的字符。 60、删去一维有序数组中所有相同的数,使之只剩一个 33、删除字符串中尾部*号,使不超过n个 36、把字符串中的前导*号全部移到字符串尾部 45、删除字符串中前导和尾部的*号 56、字符串中,除了尾部*号外,字符串中其余*号全部删除 73、删除字符串中除了前导和尾部*号外的所有*号 83、字符串中尾部*号删除 88、字符串中除了前导*外,删除其余*号 94、字符串中,前导*号全部删除 95、字符串中前导*号不得多于n个 66、删除字符串中所有*号 (4、) 17、字符串内容逆置 23、判断字符串是否为回文 25、比较两个字符串的长度(不能用strlen) 52、实现两个字符串连接 59、将字符串数组中的字符串依次合并到一个字符串中 21、字符串中字符按降序排列(选择法排序) 4、统计在tt字符串中“a”到“z”26个字母各自出现的次数,并依次放在pp所指数组中。 38、求出字符串中指定字符的个数 44、统计长度为2的字符串在另一个字符串出现的次数 62、统计一行字符串中单词个数 11、二维数组构成矩阵,使数组左下半三角元素中的值全部置成042、二维数组,将右上半角元素中的值乘以m80、二维数组中左下半三角中元素中的值乘以312、求出数组周边元素的平均值 14、求出二维数组周边元素之和 18、矩阵行列互换 53、矩阵B=A+A130、求出二维数组中最大元素的值,此值返回给调用函数 55、M行N列的二维数组中的数据,按行的顺序依次放到一维数组中 41、将二维数组中的字符,按列的顺序依次放到一个字符串中 75、二维数组中数按列的顺序放到一维数组中 13、求出二维数组每列中最小元素,并依次放在pp所指一维数组中 37、结构体数组(学号、8门成绩、平均成绩),求出每个学生的平均成绩 34、把结构体数组(学号、成绩)中分数最高的学生放到h数组中,函数返回人数 74、把结构体数组(学号、成绩)中分数最低的学生数据放在h所指数组中 50、结构体数组(学号、成绩),找出成绩最高的学生记录,通过形参返回 54、结构体数组(学号、成绩),低于平均分的学生数据放在b所指数组中 89、结构体数组(学号、成绩),高于等于平均分的学生人数通过形参返回 57、结构体数组(学号、姓名),把指定范围内的学生数据放在所指数组中 67、结构体数组(学号、成绩)返回指定学号的学生数据(查找) 46、结构体数组(学号、成绩),按分数降序排列(选择法排序) 22、链表结构中,找出数值最大的结点,并由函数值返回 85、链表中,求出平均成绩 10、迭代法求方程的实根 61、统计各年龄段人数(建议采用if else) 69、递归函数 2007年安徽省普通专升本考试大学英语真题 来源: 添加时间:2011年08月23日 关键词: 2007年安徽省普通专升本考试大学英语真题 I.(词汇,每题1分,共35题)1.Five miles ______ a long distance to an old lady of her age.A.seem to being B.seem to be C.seems to being D.seems to be 2.The computer doesn’t work well, so something ______ wrong.A.can have gone B.should have gone C.must have gone D.ought to have gone 3.A number of students in this class ______ to Beijing once or twice.A.were B.have been C.is D.has been 4.A good secretary should always be informed ______ the latest flight schedule.A.to B.in C.with D.of 5.I got the good news that they ______ in planting trees on the sandy hills.A.have succeeded B.had succeeded C.succeed D.were succeeding 6.Be sure to ______ your work at the end of the exam.A.look over B.hang up C.set aside D.catch sight of 7.The football game will be played on ______.A.June six B.six June C.the sixth of June D.the six of June 8.The police investigation discovered that three young men were ______ in the robbery.A.caught B.involved C.connected D.tightened 9.It was in that small room ______ they worked hard and dreamed of better days to come.A.what B.in which C.which D.that 10.The disk I bought from the store yesterday was found to be ______.A.empty B.blank C.vacant D.hollow 11.Please ______ the water tap when you have finished your washing.A.turn on B.turn off C.turn out D.turn over 12.If you wish to accept the invitation, please send an email to ______ you acceptance.A.confirm B.confine C.confront D.conform 13.Don’t associate with bad boys ______ your whole life will be ruined.A.or B.but C.and D.so that 14.______ George loves his daughter, he is strict with her.A.Even B.For C.Although D.Whether 15.In many cultures people insist ______ that the importance of being punctual.A.in B.over C.to D.on 16.One difficulty has been solved.But another one will ______.A.arise B.rise C.arouse D.arose 17.The classroom is quite clean ______ some waste paper on the floor.A.except for B.besides C.except D.without 18.Hold the book ______ please, for I can’t see the words in it.A.more close B.closer C.more closely D.closely 19.I shall have a companion in the house after all these ______ years.A.alone B.lonely C.single D.simple 20.He walked in the street without ______ to buy anything.A.intention B.heart C.purpose D.thought 21.You ______ if you had had higher score in the examination.A.must have got scholarship B.would have got scholarship C.should get scholarship D.had got scholarship 22.The disabled children need many things, but ______ , they need love.A.first of all B.above all C.after all D.all in all 23.______ will come and lend us a helping hand on such an awkward occasion? A.Do you suppose who B.Whom do you suppose C.Who do you think D.Whom do you think 24.He didn’t tell me where he had spent his holidays.______ to know.A.Neither I cared B.Not did I care C.I didn’t care D.Neither did I care 25.I’m for the suggestion that a special board ______ to examine the problem.A.be set up B.will be set up C.must be set up D.has to be set up 26.While studying he financially depended ______ his wife.A.on B.of C.to D.from 27.______ his sister, Jack is quite and does not easily make friends with others.A.Dislike B.Unlike C.Alike D.Liking 28.No sooner had he got home ______ it began to rain.A.when B.that C.than D.while 29.That T-shirt was so tight that he decided to have it ______.A.be enlarged B.enlarge C.enlarged D.to enlarge 30.______ is known to the world, Mark Twain is a great American writer.A.That B.Which C.As D.It 31.A lawyer’s income is usually very high, ______ more than 200,000 dollars a year.A.add up to B.added up to C.amounted to D.amounting to 32.______, the students had to go to bed.A.The lights had gone out B.The lights having gone out C.The lights went out D.The lights have gone out 33.Only in this way ______ out of the plan.A.you can talk him B.can you talk him C.him you can talk D.him can you talk 34.Most parts of the country are ______ drought.A.facing at B.coming across C.threatened with D.surrounded by 35.“The people are said to have been killed in the accident” could be rewritten as ______.A.It is said that ten people are killed in the accident.B.It was said that ten people were killed in the accident.C.It was said that ten people had been killed in the accident.D.It is said that ten people were killed in the accident.II.(完型填空,每题1分,共10题)(取自1991年6月四级真题)Geography is the study of the relationship between people and the land.Geographers compare and contrast various places on the earth.But they also go beyond the individual places and consider the earth as a 36.The word geography 37 from two Greek words, ge, the Greek word for “earth” and graphein, 38 means “to write.” The English word geography means “to describe the earth.” Some geography books focus on a small area like a town or city.Others deal with a state, a region, a nation, or an 39 continent.Many geography books deal with the whole earth.Another way to divide the study of 40 is to distinguish between physical geography and cultural geography.The former focuses on the natural world;the 41 starts with human beings and studies how human beings and their environment act upon each other.But when geography is considered as a single subject, 42 branch can neglect the other.A geographer might be described 43 one who observes, records, and explains the differences between places.If places 44 alike, there would be little need for geographers.We know, however, 45 no two places are exactly the same.Geography, then, is a point of view, a special way of looking at places.36.(A)whole(B)unit(C)part(D)total 37.(A)falls(B)removes(C)results(D)comes 38.(A)what(B)that(C)which(D)it 39.(A)extensive(B)enormous(C)overall(D)entire 40.(A)world(B)earth(C)globe(D)geography 41.(A)second(B)latter(C)next(D)later 42.(A)either(B)neither(C)one(D)each 43.(A)for(B)to(C)by(D)as 44.(A)being(B)are(C)were(D)be 45.(A)although(B)whether(C)since(D)that III.(阅读理解,前两篇每题2分,后两篇每题3分,共50分)Passage 1.(某些远程教育学校《大学英语》考试曾采用过此篇阅读理解,很简单)I remember quite clearly the first time I was really shaken by my wife’s intuition.We were looking for a second-hand car, and I had been much taken by a rather nice drop-head with a well-cared-for appearance.“Well, she runs nicely,” I told my life after the try-out.“Good start-up, engine sounds sweet, low mileage and the right price.What do you think?” “I don’t like it.” “Why not?” “I don’t know.There’s just something about the salesman that I don’t believe.” A few weeks after we had bought another car elsewhere, I happened to find out the history of the drop-head.It had been seriously damaged in a crash before we saw it, and cleverly done up.The car was, indeed, a very bad risk.Of all the things about women that their husbands do not understand, perhaps the biggest question is this: How can she often be right about things of which she has absolutely no knowledge? How does a woman’s intuition work? What is this strange power that tells her exactly when her husband isn’t working late on business, however honest he pretends to be? Is it guesswork, or some sixth sense that men don’t have? 46.When was the “first time” the husband felt “really shaken” by his wife’s intuition? A.When they bought another car.B.When he learned about the history of the drop-head..C.When he realized she knew so much about cars.D.When his wife spoke about the salesman.47.What does a person’s intuition refer to according to this passage? A.The ability to see through things.B.The ability to make a quick decision.C.The ability to pick out the best one among a number of things.D.The ability to know something by using one’s feelings.48.Why didn’t the man know that the car was damaged at first? A.The damage was not serious at all.B.He was not careful enough.C.It had been skillfully repaired.D.The salesman only tried it out smoothly.49.What answer does the writer give to a woman’s intuition? A.It is simply a blind guess.C.It must be the sixth sense.B.It is a special kind of knowledge.D.He doesn’t really answer the question.50.From the passage we learn that the salesman was _____.A.cheating B.honest C.helpful D.kind Passage 2.(出自上海教育出版社 《大学英语四级阅读200篇》 第12篇)Social customs and ways of behaving change.Things which were considered impolite many years ago are now acceptable.Just a few years ago, it was considered impolite behavior for a man to smoke on street.No man who thought of himself by smoking when a lady was in a room.Customs also differ from country to country.Does a man walk on the left or the right of a woman in your country? Or doesn't it matter? Should you use both hands when you are eating? Should leave one in your lap or on the table? The Americans and the British not only speak the same language but also share a large number of social customs.For example, in both America and England people shake hands when they meet each other for the first time.Also, most Englishmen will open a door for a woman or offer their seat to a woman, and so will most Americans.Promptness is important both in England and in America.That is , if a dinner invitation is for 7 o'clock , the dinner guest either arrives close to that time or calls up to explain his delay.The important thing to remember about social customs is not to do anything that might make other people feel uncomfortable-----especially if they are your guests.When the food was served, one of the guests started to eat his peas with a knife.The other guests were amused or shocked, but the host calmly picked up his knife and began eating in the same way.It would have been bad manners to make his guest feel foolish or uncomfortable.51.If one has accepted a dinner invitation ,what should he do if he is to be late for the dinner? A.He should find an excuse B.He should ask for excuse.C.He should say sorry D.He should telephone to explain his being late.52.“It would have been bad manners to make his guests feel foolish or uncomfortable.” “Bad manners ” means ________.A.ugly B.dishonest C.impolite D.shameful 53.which of the following do you think is the best title for this passage? A.Social Customs B.Social Life C.American and British Customs D.Promptness Is Important 54.According to the text, the best host_______.A.tries his best to make his guests feel comfortable B.makes his guests feel excited C.tries to avoid being naughty to his guests D.tries to avoid being foolish 55.The author of this article may agree with which of the following? A.The guest who ate his peas with a knife B.The other guests who were amused or shocked C.The host who picked up his knife and began eating in the same way D.None of the above Passage 3.[ 某些高中(比如杭州二中)和某些大学大一英语曾用过的阅读,难度不大] Cancer is among the top killer diseases in our society today and scientists have found out that stress helps to bring it on.It is worthwhile to consider, therefore, what are the causes of stress in our life, and whether we can do anything about it.Are we under-employed or overburdened with too many responsibilities? Do we have a right balance of work and leisure(闲暇)in our lives? Are our relationships with family, friends or fellow workers all they should be? All these things can be a cause of stress, and it is best to face them honestly, and to bring our frustrations(失意)into the open.People who have a good row and then forget it are doing their health more good than those who bottle their feelings.If our self-examination has brought any causes of stress to light, let us consider what we can do about them.It is possible to change jobs.We can make more leisure and fill it more happily, if we will accept a different living standard.We can improve our personal relationships by a different attitude.It is we who allow other people to make ourselves unhappy.Often the little things that disturb us are not worth an hour’s anger.The teaching in the Bible “ Let not the sun go down upon your wrath(anger)” is good advice from the health point of view as well as the religious.56.Which of the following statements is true? A.Freedom from responsibilities helps reduce stress B.Stress is the direct cause of cancer C.The cause of stress is worthy of serious study D.Cancer is the number one killer in our society today 57.According to the passage, which of the following types of people is more likely to suffer from stress? A.People who have cancer B.People who like to quarrel with others C.People whose living standards is low D.People who have more responsibilities than they can handle 58.Judging from the context, the word “row” in the third paragraph most probably means____.A.a noisy quarrel B.a very loud noise C.a neat line of things side by side D.a journey in a boat 59.Which of the following is not mentioned as a way to reduce our stress? A.changing our jobs B.changing our attitude to little things that make us unhappy C.speaking out our frustrations D.reading the Bible 60.“Let not the sun go down upon you wrath” probably means______.A.Don’t let your anger last long B.Don’t get angry while the sun is going down C.Don’t get angry easily about little things.D.Don’t watch the sun set while you are angry.Passage 4.[某些远程教育学校(比如四川大学网张教育学院)《大学英语3》考试题] Scientists have developed a slimming(减肥)drug that successfully suppresses appetite and results in a dramatic loss of weight without any apparent ill effects.The drug interferes with appetite control and prevents the build-up of fatty tissue.Laboratory mice given the drug lost up to a third of their total body weight.Within 20 minutes of being given the drug, called C75, the mice lost interest in eating and survived apparently content on just 10 per cent of the food they would normally eat.As a result, mice taking the drug lost 45 per cent more weight than mice fed the same amount of food, which compensate for the lack of food by becoming more lazy.Scientists, from the Johns Hopkins University in Baltimore, said that C75 is likely to produce a similar effect on humans because appetite control in brain is thought to be based on the same chemical pathways as those in mice.“We are not claiming to have found a fabled(神奇的)weight-loss drug.What we have found, using C75, is a major pathway in the brain that body uses naturally in regulating appetite at least in mice,” said Francis Kuhajda, a pathologist and senior team member.61.The newly-developed drug _______.A.controls appetite and causes obvious weight loss B.reduces weight with some ill-effect C.interferes with appetite and builds up fatty tissue D.is still going through laboratory tests 62.One of the reasons that the drug helps to lose weight is that _______.A.it helps mice sleep well B.it keeps fatty tissue from growing C.it controls eating D.it prevents overeating 63.The mice taking C75 lose nearly half of their weight on the same amount of food become _______.A.more active B.more lazy C.more aggressive D.more noisy 64.C75 is likely to produce weight-loss effect on humans because ______.A.mice and humans have similar brain structure B.human’s are likely to be more lazy than mice C.human’s appetite is regulated through the same pathway as mice’s D.mice and human body use different pathways of appetite control 65.What is the attitude of the scientists toward the slimming drug? A.indifferent B.exciting C.negative D.confident IV.(翻译 英译汉前3题每题4分,第4题6分;汉译英前3题每题4分,第4题5分; 共35分)66.Good teachers often encourage their students to think for themselves.67.Paper money is obviously easier to handle and much more convenient in the modern world.68.You must also become familiar with your teachers’ teaching styles;adjusting your learning style to theirs will be to your advantage.69.Educators think that the generation growing up with television spend so much of their time in front of the TV that they do not have enough time to study.70.我们在做出任何决定之前,应该听一听其他人的意见。71.只有在黄山,你才可以欣赏到如此的美景。 72.电子邮件使我们能够轻而易举地与远方的朋友保持联系。 73.一本好的英汉字典不是由其厚薄来评定的,而是由其质量来评定的。 IV.(作文 只要写其中一篇 20分)1.依据下列要求和内容用英文写一封应聘信: 1)收信人姓名和地址:ABC公司人力资源部(Human Resources Department)经理John Smith先生,上海市淮海西路851号(邮编200031)2)写信时间:2007年4月15日 3)信的内容必须包括: 1.假定你(写信人王华)看到ABC公司在《上海星报》(Shanghai Star)刊登招聘秘书的广告,你有意应聘这一职位; 2.写信人的年龄、毕业院校(安徽大学)、专业、特长以及相关工作经历; 3.说明自己能够胜任此项工作。 2.用英文写一篇题为“Global Shortage of Fresh Water”的文章单词。内容包括: 1)人们认为谈水是取之不尽的(提示:雨水、井水、河水等); 2)谈水紧缺的原因(提示:人口增加、工业用水增加、污染等): 3)你的建议是.......参考答案 1.DCBDB 6.ACBDB 11.BAACD 16.AABBA 21.BDCDA 26.ABCCC 31.BBBBC 36.ADCDD 41.BBDCD 46.BDCDA 51.DCAAC 56.CDADA 60.ABBCD 66.好老师总是鼓励学生独立思考。 67.在现代社会中,纸币显然更易于使用,也更加方便。 68.你也必须去熟悉老师的教学风格;而且根据这点来调整学习方法将会十分有益。 69.教育家们认为,伴随着电视机长大的一代人,在电视机前花的时间太多,以致没有足够的时间学习了。70.We should consider others’ opinion(s)before we make any decision(s).71.Only on Mount Huangshan can you enjoy/see such beautiful scenery.72.We can easily keep in touch with our friends far away by Email.73.A good English-Chinese dictionary is judged not by its thickness but by its quality. 1.编写一个程序,程序能在命令行中输出“早上好,good Morning”。 public class Hello{ public static void main(String args[]){ System.out.println(“早上好,goodMoeing”);} } 2.编写一个Java Applet程序,程序能在浏览器中显示“你好,hello”。 import java.applet.*;import java.awt.*;public class Boy extends Applet { public void paint(Graphics g){ //g.setColor(Color.blue); g.drawString(“你好,hello”,12,30);} } 3.编写一个程序,输出ASICII字母表。 public class java1 { public static void main(String[] args){ char c='!';System.out.println(“字母”+c+“在ASICII表中的顺序位置:”+(int)c);System.out.println(“输出ASICII字母表:”);for(int i=(int)c;i import java.util.*;public class ZuoYe2_1 { public static void main(String args[]){ Scanner reader=new Scanner(System.in);long s=1;int m=0;while(reader.hasNextInt()){ int x=reader.nextInt();m=m+1;s=s*x;} System.out.println(m+“个数的乘积为”+s);} } 5.有一函数:从键盘输入一个X值,程序输出Y值。 import java.util.*;public class ZuoYe2_1{ public static void main(String args[]){ double y=0,x=0;x=reader.nextDouble();if(x<0) y=-1+2*x;y=-1;y=-1+3*x;else if(x==0)else if(x>0)Scanner reader=new Scanner(System.in);} System.out.println((int)y);} 6.使用while循环计算1~1000之间能被3和7同时整除的整数之和。 public class ZuoYe2_1{ public static void main(String args[]){ } int sum=0,m=3,n=7,a=1;while(a<=1000){ if(a%m==0&&a%n==0)sum=sum+a;a++;} System.out.println(“sum=”+sum);} 7.编写一个Java应用程序,使用for循环计算8+88+888+8888+88888+…的前10项之和。 public class ZuoYe2_1{ public static void main(String args[]){ long sum=0,a=8,item=a,i=1;for(i=1;i<=10;i++){ sum=sum+item;item=item*10+a;} System.out.println(sum);} } 8.编写一个Java应用程序,计算1-1/3+1/5-1/7+1/9-1/11+…的前10000项之和。 public class ZuoYe2_1{ public static void main(String args[]){ double sum=0,a=1,b=1,f=1,item=a/b;int i=1;while(i<=1000){ sum=sum+f*item;i++;f=f*(-1);b=b+2;item=a/b;} System.out.println(“sum=”+sum);} } 9.编写一个Java应用程序,计算1+2!+3!+4!+…从100项到200项之和。 public class ZuoYe2_1{ } public static void main(String args[]){ double sum=0,a=1;int i=1;while(i<=20){if(i>=10)sum=sum+a;i++;a=a*i;} System.out.println(“sum=”+sum);} 10.编写一个类,该类创建的对象可以计算等差数列的和。 class DengCha{ int start,d;DengCha(){} DengCha(int start,int d){ this.start=start;this.d=d;} void setStart(int s){ start=s;} void setD(int d){ this.d=d;} int getSum(int n){ int sum=0,i=1;while(i<=n){ sum=sum+start;start=start+d;i++;} return sum;} } public class ZuoYe2_1{ public static void main(String args[ ]){ } DengCha shulie=new DengCha(2,3);shulie.setStart(10);shulie.setD(5);System.out.println(shulie.getSum(9));} System.out.println(shulie.getSum(100));11.编一个类,该类创建的对象可以输出英文字母表。 class Letter{ public void printLetter(){ for(char c='a';c<='z';c++)System.out.print(“ ”+c);} } public class ZuoYe2_1{ public static void main(String args[ ]){ } Letter p=new Letter();p.printLetter();} 12.编一个类,该类封装了一元二次方程共有的属性和功能,即该类有刻画方程系数的三个成员变量以及计算实根的方法。要求:该类的所有对象共享常数项。 class SquareEquation{ double a,b;static double c;double root1,root2;boolean boo;public SquareEquation(double a,double b,double c){ this.a=a;this.b=b;SquareEquation.c=c;if(a!=0){boo=true;} else{ boo=false;} } public void getRoots(){ if(boo){ System.out.println(“是一元2次方程”);double disk=b*b-4*a*c;if(disk>=0){ root1=(-b+Math.sqrt(disk))/(2*a);root2=(-b-Math.sqrt(disk))/(2*a);System.out.printf(“方程的根:%f,%fn”,root1,root2);} else{ System.out.printf(“方程没有实根n”);} } else{ System.out.println(“不是一元2次方程”);} } public void setCoefficient(double a,double b,double c){ this.a=a;this.b=b;SquareEquation.c=c;if(a!=0){boo=true;} else{boo=false;} } } public class ZuoYe2_1{ public static void main(String args[ ]){ SquareEquation equation1=new SquareEquation(4,5,1);SquareEquation equation2=new SquareEquation(3,5,-7); equation1.getRoots();equation2.getRoots();} } 13.编写两个类,A和B,类A创建的对象可以计算两个正整数的最大公约数,类B创建的对象可以计算两个书的最小公倍数。要求:类B中有一个成员变量是用类A的声明对象。 import java.util.Scanner;class A{ int f(int m,int n){ if(m*n<0){ System.out.println(“有负数,程序退出”);System.exit(0);} if(m int m=reader.nextInt();System.out.print(“输入第二个整数:”); int n=reader.nextInt();A a=new A();B b=new B();System.out.println(m+“和”+n+“的最大公约数是”+a.f(m,n));System.out.println(m+“和”+n+“的最小公倍数是”+b.g(m,n));}} 14.编写使用了包语句的类,然后在应用程序中用import语句引入该类,并用该类创建对象。 import java.applet.Applet;import java.awt.*;public class ZuoYe2_1 extends Applet{ Button redbutton;public void init(){ redbutton=new Button(“我是一个红色的按钮”);redbutton.setBackground(Color.red);redbutton.setForeground(Color.white);add(redbutton);} } 15.编写一个类,该类有一个方法 Public int f(int a,int b){ //要求该方法返回a和b的最大公约数 } 然后编写一个该类的子类,要求子类重写方法f(),而且重写的方法将返回两个整数的最小公倍数。要求:在成功写的方法的方法体中首先调用被隐藏的方法返回a和b的最大公约数m,然后将(a*b)/m返回;在应用的程序的主类中分别使用父类和子类创建对象,并分别调用方法f()计算两个正整数的最大公约数和最小公倍数。 import java.util.Scanner;class A{ public int f(int m,int n){ if(m int m=reader.nextInt();System.out.print(“输入第二个整数:”); int n=reader.nextInt();if(m*n<0){ System.out.println(“有负数,程序退出”);System.exit(0);} System.out.printf(“%d和%d的最大公约数是%dn”,m,n,a.f(m,n));System.out.printf(“%d和%d的最小公倍数是%dn”,m,n,b.f(m,n));} } 16.首先编写一个抽象类,要求该类有如下3个抽象方法: Public abstract void f(int x); Public abstract void g(int x.int y); Public abstract double h(double x); 然后分别给出该类的3个子类。要求:在应用程序的主类中使用这些子类创建对象,然后让它们的上转型对象调用方法:f(),g()和h()。 abstract class A{ public abstract void f(int x);public abstract void g(int x,int y);public abstract double h(double x);} class A1 extends A{ public void f(int x){ System.out.println(x);} public void g(int x,int y){ int z=x+y;System.out.println(z);} public double h(double x){ return x*x;} } class A2 extends A{ public void f(int x){ System.out.println(“Hello:”+x);} public void g(int x,int y){ int z=x-y;System.out.println(z);} public double h(double x){ return Math.sqrt(x);} } class A3 extends A{ public void f(int x){ System.out.println(“你好:”+x);} public void g(int x,int y){ double z=(double)x/y;System.out.println(z);} public double h(double x){ return 1/x;} } public class ZuoYe2_1 { public static void main(String args[ ]){ A a=new A1();a.f(10);a.g(12,20);System.out.println(a.h(100));a=new A2();a.f(10);a.g(12,20);System.out.println(a.h(100));a=new A3();a.f(10);a.g(12,20);System.out.println(a.h(100));} } 17.编写一个类,要求该类实现一个接口,该接口有如下3个抽象方法: Public abstract void f(int x); Public abstract void g(int x.int y); Public abstract double h(double x); 要求:在应用程序的主类中使用该类创建对象,并使用接口回调来调用方法:f(),g()和h()。 interface A{ public abstract void f(int x);public abstract void g(int x,int y);public abstract double h(double x);} class A1 implements A{ public void f(int x){ System.out.println(x);} public void g(int x,int y){ int z=x+y;System.out.println(z);} public double h(double x){ return x*x;} } class A2 implements A{ public void f(int x){ System.out.println(“Hello:”+x);} public void g(int x,int y){ int z=x-y;System.out.println(z);} public double h(double x){ return Math.sqrt(x);} } class A3 implements A{ public void f(int x){ System.out.println(“你好:”+x);} public void g(int x,int y){ double z=(double)x/y;System.out.println(z);} public double h(double x){ return 1/x;} } public class ZuoYe2_1 { public static void main(String args[ ]){ A a=new A1();a.f(10);a.g(12,20);System.out.println(a.h(100));a=new A2();a.f(10);a.g(12,20);System.out.println(a.h(100));a=new A3();a.f(10);a.g(12,20);System.out.println(a.h(100));} } 18.举例说明匿名类的用法。class Cubic { double getCubic(int n){ return 0;} } abstract class Sqrt{ public abstract double getSqrt(int x);} class A{ void f(Cubic cubic){ double result=cubic.getCubic(3);System.out.println(result);} } public class ZuoYe2_1 { public static void main(String args[]){ A a=new A(); a.f(new Cubic(){ return n*n*n;} });Sqrt ss=new Sqrt(){ public double getSqrt(int x){ return Math.sqrt(x);} };double m=ss.getSqrt(5);System.out.println(m);} } { double getCubic(int n)19.编写一个异常类,并具体给出一个产生该异常的方法。在一个应用程序中测试该异常类。class IntegerException extends Exception { String message;IntegerException(int m){ message=“年龄”+m+“不合理”;} public String toString(){ return message;} } class People { private int age=1;public void setAge(int age)throws IntegerException{ if(age>=160||age<=0)throw new IntegerException(age);else this.age=age;} public int getAge(){ System.out.println(“年龄”+age+“合理”);return age;} } public class ZuoYe2_1 { public static void main(String args[]){ People wang=new People(), zhang=new People();try { wang.setAge(189);System.out.println(wang.getAge());} catch(IntegerException e)try { zhang.setAge(28);System.out.println(zhang.getAge());} catch(IntegerException e){ System.out.println(e.toString());} } } { System.out.println(e.toString());} 20.编写一个应用程序,用户从键盘输入一行字符串,程序输出该字符串中与模式”[24680]A[13579]{2}”匹配的子字符串。 import java.util.regex.*;import java.util.*;public class ZuoYe2_1 { public static void main(String args[ ]){ Scanner reader=new Scanner(System.in);String s1=reader.nextLine();Pattern p;m=p.matcher(s1);while(m.find()){ String str=m.group();System.out.print(“从”+m.start()+“到”+m.end()+“匹配模式子序列:”);System.out.println(str);} } } 21.编写一个应用程序,用户从键盘输入一行含有数字字符的字符串,程序仅仅输出字符串中的全部数字字符。import java.util.regex.*;import java.util.*;public class ZuoYe2_1 { public static void main(String args[ ]){ Scanner reader=new Scanner(System.in); String s1=reader.nextLine();Pattern p;Matcher m;Matcher m;p=Pattern.compile(“[24680]A[13579]{2}”);p=Pattern.compile(“d+”);m=p.matcher(s1);while(m.find()){ String str=m.group();System.out.print(str);} } } 22.设计5个人排队买票,并规定卖票规则和排队顺序。//设计如下: 一张电影票5元。卖票员有一张10元。买票人:A-5元,B-5元,C-10元,D-10元,E-20元。 public class ZuoYe2_1 { public static void main(String args[]){ String s1=“A”,s2=“B”,s3=“C”, s4=“D”,s5=“E”;Cinema canema=new Cinema(s1,s2,s3,s4,s5); Thread a,b,c,d,e;a=new Thread(canema);b=new Thread(canema);c=new Thread(canema);d=new Thread(canema);e=new Thread(canema);a.setName(s1);b.setName(s2);c.setName(s3);d.setName(s4);e.setName(s5);a.start();b.start(); c.start();d.start();e.start();} } TicketSeller seller;String name1,name2,name3,name4,name5;seller=new TicketSeller();name1=s1;name2=s2;name3=s3;name4=s4;name5=s5;} public void run(){ class Cinema implements Runnable{ Cinema(String s1,String s2,String s3,String s4,String s5){ if(Thread.currentThread().getName().equals(name1)){seller.sellTicket(5);} else if(Thread.currentThread().getName().equals(name2)){seller.sellTicket(5);} else if(Thread.currentThread().getName().equals(name3)){seller.sellTicket(10);} else if(Thread.currentThread().getName().equals(name4)){seller.sellTicket(10);} else if(Thread.currentThread().getName().equals(name5)){seller.sellTicket(20);} } class TicketSeller{ int fiveNumber=0,tenNumber=1, twentyNumber=0;public synchronized void sellTicket(int receiveMoney){ String s=Thread.currentThread().getName();if(receiveMoney==5){ fiveNumber=fiveNumber+1;System.out.println(s+“给售票员5元钱,售票员卖给”+s+“一张票,不必找赎”);} else if(receiveMoney==10){ while(fiveNumber<1){ try{ System.out.println(s+“给售票员10元 } 钱”);System.out.println(“售票员请”+s+“靠边等一 会”);wait(); System.out.println(s+“结束等待,继续买 票”);} catch(InterruptedException e){}} fiveNumber=fiveNumber-1;tenNumber=tenNumber+1;System.out.println(s+“给售票员10元钱,售票员卖给”+s+“一张票,找赎5元”);} else if(receiveMoney==20){ while(fiveNumber<1||tenNumber<1){ try{ System.out.println(s+“给售票员20元钱”);System.out.println(“售票员请”+s+“靠边等一 会”);wait(); System.out.println(s+“结束等待,继续买 票”);} catch(InterruptedException e){}} fiveNumber=fiveNumber-1;tenNumber=tenNumber-1;twentyNumber=twentyNumber+1;System.out.println(s+“给售票员20元钱,售票员卖给”+s+“一张票,找赎15元”);} notifyAll();} } 23.编写一个应用程序,读取一个文本文件的内容。import java.io.*;import java.awt.*;import java.awt.event.*;public class ZuoYe2_1 { public static void main(String args[]){ int b; byte tom[]=new byte[25];try{ File f=new File(“Example.java”);FileInputStream in= new FileInputStream(f);while((b=in.read(tom,0,25))!=-1){ String s=new String(tom,0,b);System.out.print(s);} in.close();} catch(IOException e){ System.out.println(“File read Error”+e);}}} 24.编写一个应用程序,将用户从键盘输入的10行文字存入文件。import java.io.*;import java.util.*;public class ZuoYe2_1 { public static void main(String args[]){ Scanner reader=new Scanner(System.in);int b;try{ FileOutputStream writefile= new FileOutputStream(“line.txt”);int line=1,n=10;System.out.println(“输入”+n+“行文本,并存入磁盘:”);while(line<=n){ String s=reader.nextLine();byte buffer[]=s.getBytes();writefile.write(buffer,0,buffer.length);line++;} writefile.close();} catch(IOException e){ System.out.println(“Error ”+e);} } } 25.使用数组字符流将俄文字母写入内存,然后再从内存读出。import java.io.*;public class ZuoYe2_1 { public static void main(String args[ ]){ int n=-1;new CharArrayWriter();for(char c='а';c<='я';c++){ out.write(c);} CharArrayReader in= new CharArrayReader(out.toCharArray());try{ while((n=in.read())!=-1){ if(n%2==0){ System.out.printf(“n”);} System.out.printf(“t位置%d,字符'%c'”,n,(char)n);} } catch(IOException e){} } } CharArrayWriter out= 26.编写一个应用程序,将用户从键盘输入的10个整数存入文件,然后按顺序读出。 import java.io.*;import java.util.*;public class ZuoYe2_1 { public static void main(String args[]){ try{ FileOutputStream fos=new FileOutputStream(“jerry.dat”);DataOutputStream out_data= new DataOutputStream(fos);Scanner reader=new Scanner(System.in);for(int i=1;i<=10;i++){ int x=reader.nextInt();out_data.writeInt(x);} out_data.close();} try{ new FileInputStream(“jerry.dat”);DataInputStream in_data= new DataInputStream(fis);for(int i=1;i<=10;i++){ catch(IOException e){} FileInputStream fis= } int m=in_data.readInt();in_data.close();} catch(IOException e){} } System.out.print(“ ”+m);} 27.编写一个应用程序,要求将LinkedList import java.io.*;import java.util.*;class Student implements Serializable{ String name;int number;Student(String name,int number){ this.name=name;this.number=number;} } public class ZuoYe2_1 { public static void main(String args[]){ List 29.编写一个应用程序,在应用程序中有一个按钮和一个文本框。当单击按钮时,文本框显示按钮的名字。import java.awt.*;import java.awt.event.*;import javax.swing.*;public class ZuoYe2_1 { public static void main(String args[]){ MathWindow win=new MathWindow();} } class MathWindow extends JFrame{ JTextField inputText;JButton button;MathWindow(){ inputText=new JTextField(10);button=new JButton(“hello”);button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ inputText.setText(button.getText());}}); setLayout(new FlowLayout());add(inputText);add(button);setBounds(100,100,260,190);setVisible(true);validate();setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);} } random.seek(0);long m=random.length();while(m>=0){ m=m-1;random.seek(m);int c=random.readByte();if(c<=255&&c>=0){ System.out.print((char)c);} else { m=m-1;random.seek(m);byte cc[]=new byte[2];random.readFully(cc);System.out.print(new String(cc));} } random.close();} } catch(IOException ee){}} 30.编写一个有两个文本框和一个按钮的应用程序,在一个文本框输入一个字符串按回车键或单击按钮,另一个文本框都显示字符串中每个字符在Unicode表中的顺序位置。 import java.awt.*;import java.awt.event.*;import javax.swing.*;public class ZuoYe2_1 { public static void main(String args[]){ MathWindow win=new MathWindow();} } JTextField inputText,showUnicode;JButton button;MathWindow(){ inputText=new JTextField(10);showUnicode=new JTextField(10);button=new JButton(“enter”);button.addActionListener(this);inputText.addActionListener(this);setLayout(new FlowLayout());add(inputText);add(button);add(showUnicode);setBounds(100,100,260,190);setVisible(true);validate();setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);} String s=inputText.getText();StringBuffer str=new StringBuffer();for(int i=0;i import java.awt.*;import java.awt.event.*;import javax.swing.*;public class ZuoYe2_1 { public static void main(String args[]){ ComputerFrame fr= new ComputerFrame(); fr.setTitle(“计算”);} } class ComputerFrame extends JFrame implements ActionListener{ JTextField text1,text2,text3; JButton button1,button2,button3,button4;JLabel label;public ComputerFrame(){ setLayout(new FlowLayout());text1=new JTextField(10);text2=new JTextField(10);text3=new JTextField(10);label=new JLabel(“ ”,JLabel.CENTER);label.setBackground(Color.green);add(text1);add(label);add(text2);add(text3);button1=new JButton(“加”);button2=new JButton(“减”);button3=new JButton(“乘”);button4=new JButton(“除”);add(button1);add(button2);add(button3);add(button4);button1.addActionListener(this);button2.addActionListener(this);button3.addActionListener(this);button4.addActionListener(this);setSize(300,320);setVisible(true);addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0);} });validate();} { double n;if(e.getSource()==button1){ double n1,n2;public void actionPerformed(ActionEvent e)try{ n1=Double.parseDouble(text1.getText());n2=Double.parseDouble(text2.getText());n=n1+n2;label.setText(“+”);} text3.setText(String.valueOf(n));catch(NumberFormatException ee){ text3.setText(“请输入数字字符”);} } else if(e.getSource()==button2){ double n1,n2;try{ n1=Double.parseDouble(text1.getText());n2=Double.parseDouble(text2.getText()); n=n1-n2;text3.setText(String.valueOf(n));label.setText(“-”);} catch(NumberFormatException ee){ text3.setText(“请输入数字字符”);} } else if(e.getSource()==button3){double n1,n2;try{ n1=Double.parseDouble(text1.getText());n2=Double.parseDouble(text2.getText());n=n1*n2;label.setText(“*”);} text3.setText(String.valueOf(n));catch(NumberFormatException ee){ text3.setText(“请输入数字字符”);} } else if(e.getSource()==button4){double n1,n2;try{ n1=Double.parseDouble(text1.getText());n2=Double.parseDouble(text2.getText()); n=n1/n2;text3.setText(String.valueOf(n));label.setText(“/”);} catch(NumberFormatException ee){ text3.setText(“请输入数字字符”);} } validate();} } 32.编写一个应用程序,要求有一个含有菜单的窗口,窗口中有文本区组件。菜单有“打开文件”的菜单项,当单击该菜单项时,使用输入流将一个名字为“hello.txt”文件的内容读入到文本中。 import javax.swing.*;import java.awt.event.*;import java.awt.*;import java.io.*;public class ZuoYe2_1 { public static void main(String args[]){ new ReadFileWindow();} } JMenuBar menubar;JMenu menu;JMenuItem openFile;JTextArea showText;ReadFileWindow(){ menubar=new JMenuBar();menu=new JMenu(“文件”);openFile=new JMenuItem(“打开文件”);menu.add(openFile);class ReadFileWindow extends JFrame implements ActionListener{ menubar.add(menu);setJMenuBar(menubar);showText=new JTextArea(12,12);add(new JScrollPane(showText));validate();setBounds(120,120,500,370);setVisible(true);openFile.addActionListener(this);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);} public void actionPerformed(ActionEvent e){ String fileName=“hello.txt”;File readFile=new File(fileName);showText.setText(null);new FileReader(readFile);BufferedReader inTwo= new BufferedReader(inOne); String s=null;int i=0;while((s=inTwo.readLine())!=null)inOne.close();inTwo.close();} try{ FileReader inOne= showText.append(“n”+s);catch(IOException ex){ showText.setText(ex.toString());} } } 33.编写有两个文本区的应用程序。当我们在一个文本区中输入若干个数时,另一个文本区同时对输入的数进行求和运算并求出平均值,也就是说随着输入的变化,另一个文本区不断地更新求和及平均值。34.编写一个应用程序,有8个按钮,用户通过按动键盘上的方向键移动这些按钮。 import java.awt.*;import java.awt.event.*;import javax.swing.*;public class ZuoYe2_1 { public static void main(String args[]){ Win win=new Win();}} class Win extends JFrame implements KeyListener{ JButton b[]=new JButton[8];int x,y;Win(){ setLayout(new FlowLayout());for(int i=0;i<8;i++){ b[i]=new JButton(“"+i);add(b[i]);} b[i].addKeyListener(this);addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0);}});setBounds(10,10,300,300); setVisible(true);validate();} public void keyPressed(KeyEvent e){ int moveDistance=1;Component com=(Component)e.getSource();int x=(int)com.getBounds().x;int y=(int)com.getBounds().y;{ y=y-moveDistance;com.setLocation(x,y);Rectangle comRect=com.getBounds();for(int k=0;k if(x<=0)x=0;} else if(e.getKeyCode()==KeyEvent.VK_RIGHT){ x=x+moveDistance;com.setLocation(x,y);for(int k=0;k 35.编写一个应用程序,用户可以在一个文本框里输入数字字符,按回车后将数字存入一个文件。当输入的数字大于1000时,弹出一个有模式的对话框,提示用户数字已经大于1000,是否继续将该数字存入文件(建议使用RandomAcessFile流实现信息的写入)。 import java.awt.event.*;import java.awt.*;import javax.swing.*;import java.io.*;public class ZuoYe2_1 { public static void main(String args[]){ new Dwindow();}} class Dwindow extends JFrame implements ActionListener { JTextField inputNumber;JTextArea show;Dwindow(){ inputNumber=new JTextField(22);inputNumber.addActionListener(this);show=new JTextArea();add(inputNumber,BorderLayout.NORTH);add(show,BorderLayout.CENTER);setBounds(60,60,300,300);setVisible(true);validate();setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);} public void actionPerformed(ActionEvent e){ boolean boo=false;if(e.getSource()==inputNumber){ String s=inputNumber.getText();for(int i=0;i saveNumber(number);} } } void saveNumber(int n){ RandomAccessFile out=null;try{ out=new RandomAccessFile(”a.dat“,”rw“);out.seek(out.length());out.writeUTF(”integer:");out.writeInt(n);out.close();} catch(Exception e){} } }第三篇:编程题总结
第四篇:2007年安徽省普通专升本考试大学英语真题
第五篇:2010年秋季Java考试编程题总结