中石油华东2015年春季学期《C语言》在线考试(适用于2015年6月份考试))满分答案
- 格式:doc
- 大小:31.00 KB
- 文档页数:8
《C语言》2019年春季学期在线作业(一)
若有:inta[10],*p=&a[0];,关于数组名a的不正确的说法是()。
A.a是个数组指针
B.数组名a表示数组的首地址
C.数组名a与a[0]等价
D.a和p都指向同一个存储单元
【华东石油】本题答案:A
在调用函数时,如果实参是简单变量,它与对应形参之间的数据传递方式是
A.地址传递
B.由实参传给形参,再由形参返回实参
C.值传递
D.传递方式由用户指定
【华东石油】本题答案:C
有以下函数定义:voidfun(intn,doublex){}若以下选项中的变量都已正确定义并赋值,则对函数fun的正确调用语句是
A.fun(inty,doublem)
B.k=fun(10,12.5)
C.fun(10,12.5)
D.voidfun(10,12.5);
【华东石油】本题答案:C
以下选项中,与k=n完全等价的表达式是
A.k=n,n=n1。
C语言复习题【设计型】5.1 输出一行星号编写程序在一行中输出 N 个星号。
输入: N值输出:一行中N个星号#include<stdio.h>int main(){int a,i;scanf("%d",&a);for(i=1;i<=a;i++)printf("*");printf("\n");return 0;}【设计型】5.2 打印平行四边形输入图形的高 n ,输出如下例( n=5 )所示的图形 .*************************输入:整数n例如 5由*组成的高为5的平行四边形#include<stdio.h>int main(){int i,j,num;scanf("%d",&num);for(i=0;i<num;i++){for(j=0;j<num;j++)printf("*");printf("\n");}return 0;}【设计型】5.3 编程计算编写程序,输入n的值,求 :1-1/2+1/3-1/4+1/5-1/6+1/7-...+1/n (保留四位小数) #include<stdio.h>int main(){double n,i,sum,k=1.0;scanf("%lf",&n);i=1,sum=0;while(i<=n)sum=sum+k/i;i++;k=-k;(用这个式子实现正负交替)}printf("sum=%.4lf\n",sum);return 0;}【设计型】5.4 分数序列有一个分数序列:...............,输入整数n,求出其前n项的和。
输出语句格式为:printf("sum=%16.10f\n",s);#include<stdio.h>int main(){int n,a,b,i,temp;double sum;scanf("%d",&n);i=1,sum=0,a=2,b=1;while(i<=n){sum=sum+a*1.0/b;temp=a;a=a+b;b=temp;(几个式子实现数值的变换)i++;}printf("sum=%16.10f\n",sum);return 0;}【设计型】5.5 求e的值编写程序,从键盘输入整数 n , 求 e 的值 . e=1+1/1!+1/2!+1/3!+..+1/n! 注意:用 double 型数据计算输出语句:printf("sum=%16.10f\n",sum);#include<stdio.h>int main(){int n,i;double sum,jc;scanf("%d",&n);i=1,sum=1.0 jc=1.0;while(i<=n){jc=jc*i;sum=sum+1.0/jc;i++;}printf("sum=%16.10f\n",sum);return 0;}【设计型】5.6 最大公约数输入两个正整数m和n,求它们的最大公约数和最小公倍数比如,输入m和n的值分别为14和21,则最大公约数为7,最小公倍数为42。
中国石油大学(华东)C语言在线测评答案第10章字符串(2013级亲测正确)10.1 字符转换描述提取一个字符串中的所有数字字符(‘0’...‘9’)将其转换为一个整数输出。
输入一个以回车符为结束标志的字符串(少于80个字符)。
输出把字符串中的所有数字字符(‘0’...‘9’)转换为一个整数并输出。
#include<stdio.h>#include<string.h>int main(){char s[80];int i,k,n=0;gets(s);k=strlen(s);for(i=0;i<k;i++)if(s[i]>='0'&&s[i]<='9')n=n*10+(s[i]-'0');printf("%d\n",n);return 0;}10.2 合并字符串输入两个已经按从小到大顺序排列好的字符串,编写一个合并两个字符串的函数,使合并后的字符串,仍然是从小到大排列。
输入:两个已经排好顺序(升序)的字符串输出:一个合并在一起的有序(升序)的字符串要求:设计一个效率尽量高的算法,对每个字符串只扫描一遍就可以了。
如果采用先进行串连接,然后再进行排序的算法,则效率太低了。
#include<stdio.h>#include<string.h>int main(){char a[100],b[100],t;int k,i,j;gets(a); gets(b);strcat(a,b);k=strlen(a);/*冒泡法排序*/for(i=1;i<k;i++) /*不能用字符串数组最后一项'\0'和前面项比较,故i从1开始*/ for(j=0;j<k-i;j++)if(a[j]>a[j+1]){ t=a[j];a[j]=a[j+1];a[j+1]=t; }puts(a);return 0;}10.3 删除重复字符背景:输入一个长度不超过 100 的字符串,删除串中的重复字符。
2015年春季学期《C语言》补考在线考试(适用于2015年10月份考试)试卷总分:100 测试时间:--单选题简答题其他题一、单选题(共10 道试题,共20 分。
)V1. 以下非法的赋值语句是A. n=(i=2, i);B. j ;C. (i 1);D. x=j>0;正确答案:C 满分:2 分2. 已定义c为字符型变量,则下列语句中正确的是A. c='97';B. c="97";C. c="a";D. c=97;正确答案: D 满分:2 分3. 表示x≤0或x≥1的正确的表达式是A. x>=1||x<=0B. x>1 || x<=0C. x>=1 or x<=0D. x>=1 || x<0正确答案:A 满分:2 分4. 以下非法的赋值语句是A. n=(i=2, i);B. j ;C. (i 1);D. x=j>0;正确答案: C 满分:2 分5. 已知int a=4,b=5; ,这执行表达式a=a>b 后,变量a的值为A. 0B. 1C. 4D. 5正确答案:A 满分:2 分6. 设有语句:float x=1,y; y=x 3/2; 则y的值是A. 1B. 2C. 2.0D. 2.5正确答案:C 满分:2 分7. 假设已定义char c[8]= "test";int i;则下面的输出函数调用中错误的是A. printf("%s",c);。
中石油《C语言》2019年春季学期在线作业(一)
一、单选题共20题,100分
1、若有:int a[10],*p=&a[0];,关于数组名a的不正确的说法是()。
Aa是个数组指针
B数组名a表示数组的首地址
C数组名a与a[0]等价
Da和p都指向同一个存储单元
【答案选择】:A
2、在调用函数时,如果实参是简单变量,它与对应形参之间的数据传递方式是
A地址传递
B由实参传给形参,再由形参返回实参
C值传递
D传递方式由用户指定
【答案选择】:C
3、有以下函数定义: void fun( int n , double x ) { …… } 若以下选项中的变量都已正确定义并赋值,则对函数fun的正确调用语句是
Afun( int y , double m )
Bk=fun( 10 , 12.5 )
Cfun( 10 , 12.5 )
Dvoid fun( 10 ,12.5 );
【答案选择】:C
4、以下选项中,与k= n完全等价的表达式是
Ak=n,n=n 1
Bn=n 1,k=n
Ck= n
Dk =n 1
【答案选择】:B
5、在C语言中,下列变量名称中合法的是
A7x。
中石油华东2015年春季学期《大学英语 2》在线考试(适用于2015年6月份考试)满分答案1. She is working very hard to ______ the lost time at school.A. make forB. make up forC. make upD. make ou正确答案:B 满分:1 分得分:12. With the problem ______, we are getting along even more smoothly.A. settlesB. to settleC. settledD. to be settling正确答案:C 满分:1 分得分:13. __________ our records, the books you have borrowed should now be returnedto the library.A. Due toB. ConcerningC. Regardless ofD. According to正确答案:D 满分:1 分得分:14. —Do you mind if I smoke here? —__________A. Yes, certainly not.B. No, please don’t.C. Sorry, it’s forbidden here.D. Yes, I mind.正确答案:C 满分:1 分得分:15. —Excuse me, when is the next flight from London due to arrive? —_________A. In half an hour.B. An hour before.C. Until the next one.D. Before another one.正确答案:A 满分:1 分得分:16. ______ only five minutes to finish the task.A. I took myselfB. It required meC. It took meD. It needed me正确答案:C 满分:1 分得分:17. —I’m glad you like it. Please drop in any time you like. —__________A. Yes, I will.B. I’m afraid I won’t be free.C. Is it all right?D. That’s great.正确答案:A 满分:1 分得分:18. Tom ______ be at home because he telephoned me from Beijing just a moment ago.A. mustn’tB. isn’t able toC. can’tD. may not正确答案:C 满分:1 分得分:19. Shanghai is the place _____ the great Communist Party of China was born.A. whichB. whereC. whenD. that正确答案:B 满分:1 分得分:110. Jack and Bill are twins, but the former is taller than ________.A. laterB. lateC. latestD. the latter正确答案:D 满分:1 分得分:111. ______ one occasion he helped an old woman who was in danger ______ the risk of his life.A. In, asB. On, atC. By, withD. At, in正确答案:B 满分:1 分得分:112. Her son promised __________ in the bedroom until the baby stopped__________.A. staying, to cryB. to stay, cryingC. for staying, to cryD. to stay, to cry正确答案:B 满分:1 分得分:113. —I'm afraid I have spilled some coffee on the table cloth. —____________A. Oh, don't worry about that.B. You needn’t apologize.C. I feel sorry for that.D. Oh, you shouldn’t have done that.正确答案:A 满分:1 分得分:114. —May I see the menu, please? I’ve been waiting an hour already. —_________.A. That is the menu, sirB. Yes, please go onC. Here you are, sirD. Of course, sir正确答案:C 满分:1 分得分:115. —Do you think living in the countryside has more advantages? —____________A. Yes, perfectly.B. Well, it depends.C. Yes, it is.D. Nothing at all.正确答案:B 满分:1 分得分:116. Since he was ______ to the post of school principal, he has had complaints from the students and their parents.A. assignedB. awardedC. arrangedD. afforded正确答案:A 满分:1 分得分:117. —George, I would like to introduce a friend of mine, if I may: Albert Snow. Albert, this is George Smith. —____________A. How have you been?B. Pleased to meet you, George.C. Mind if call you George?D. The pleasure’s mine.正确答案:B 满分:1 分得分:118. Clothes and blankets have been __________ among the refugees.A. distributedB. contributedC. attributedD. conducted正确答案:A 满分:1 分得分:119. Someone called me up in the middle of the night, but they hung up ______ I could answer the phone.A. asB. sinceC. untilD. before正确答案:D 满分:1 分得分:120. —It’s really nice of you to give me a hand in time! —____________A. Thank you.B. No, no.C. With pleasure.D. It’s my pleasure.正确答案:D 满分:1 分得分:121. —You look tired. What’s the matter? —______________A. It doesn’t matter.B. Oh, my head aches badly.C. It is not the matter.D. Don’t worry.正确答案:B 满分:1 分得分:122. The columnist feels sure ______ wins the election will have the support of the parties.A. whoeverB. whomeverC. whateverD. whenever正确答案:A 满分:1 分得分:123. —Do you mind telling me where you’re from? —_________.A. Certainly. I’m from LondonB. Sure. I was born in LondonC. Not really, you can do itD. Certainly not. I’m from London正确答案:D 满分:1 分得分:124. —Which one do you prefer, the window seat or the aisle seat?—_____________A. I prefer a window seat.B. I like neither.C. Both will do.D. I don’t know.正确答案:A 满分:1 分得分:125. —I’m sorry. Bob’s not in his office. —_________A. Would you like to leave a message?B. Are you sure for that?C. Can you take a message for me?D. Can you phone me?正确答案:C 满分:1 分得分:126. Sports, ______ perhaps you don’t like very much, may make you strong.A. thatB. itC. whichD. what正确答案:C 满分:1 分得分:127. If you don’t ______ at least one of the conditions, you can’t becomea member of our club.A. pleaseB. satisfyC. interestD. mention正确答案:B 满分:1 分得分:128. —You seem to have a lot of work to do in your office. You’ve always been working overtime. —____________A. You are right, but don’t you know the meaning of work?B. Sorry, I don’t think so. I get overpaid for overwork, you know.C. That’s right. All work and no play make Jack a dull boy.D. That’s right, but the work is interesting. I don’t mind some extra hours at正确答案:D 满分:1 分得分:129. —I think the movie is really exciting and touching. —____________A. So am I.B. So do I.C. Neither do I.D. The same to you.正确答案:B 满分:1 分得分:130. The young couple _______ their new life to a railway train on a longunknown track.A. imaginedB. figuredC. comparedD. cheered正确答案:C 满分:1 分得分:1二、完型填空(共1 道试题,共20 分。
中石油华东2014年春季学期《Visual FoxPro》在线考试(适用于2014年6月份考试)单选题判断题主观填空题论述题一、单选题(共40 道试题,共40 分。
)1. 在Visual FoxPro中存储图像的字段类型应该是()。
A. 字符型B. 通用型C. 备注型D. 双精度型-----------------选择:B2. 以下关于Visual FoxPro的叙述最全面的是()。
A. Visual FoxPro是一个数据库应用平台软件B. Visual FoxPro是一个数据库应用开发工具C. Visual FoxPro是一个综合应用软件D. Visual FoxPro既是一个数据库应用平台,又是数据库应用开发工具-----------------选择:D3. 函数运算YEAR(date( ))返回值的类型是()。
A. 逻辑型B. 字符型C. 备注型D. 数值型-----------------选择:D4. 作为数据库管理系统(DBMS)功能的一部分,()被用来描述数据及其联系。
A. 数据定义语言B. 自含语言C. 数据操作语言D. 过程化语言-----------------选择:C5. 假定学生关系是S(S#,SNAME,SEX,AGE),课程关系是C(C#,CNAME,TEACHER),学生选课关系是SC(S#,C#,GRADE)。
要查找选修“COMPUTER”课程的“女”学生姓名,将涉及到关系()。
A. SB. SC,CC. S,SCD. S,C,SC-----------------选择:D6. 由计算机、操作系统、数据库管理系统、数据库、应用程序及用户组成的一个整体叫()。
A. 软件系统B. 数据库系统C. 管理系统D. 文件系统。
中石油华东2015年春季学期《C语言》在线考试(适用于2015年6月份考试)
试卷总分:100 测试时间:--
单选题简答题其他题
一、单选题(共10 道试题,共20 分。
)V 1. 表示x≤0或x≥1的正确的表
达式是
A. x>=1||x<=0
B. x>1 || x<=0
C. x>=1 or x<=0
D. x>=1 || x<0
满分:2 分
正确答案:A
2. 设有如下程序段:
int x=2, y=3;
printf("%d\n",(x,y));
则以下叙
述中正确的是
A. 输出语句中格式说明符的个数少于输出项的个数,不能正确输出
B. 运行时产生出错信息
C. 输出值为2
D. 输出值为3
满分:2 分
正确答案:D
3. C语言中基本数据类型有
A. 整型、实型、逻辑型
B. 整型、字符型、逻辑型
C. 整型、实型、字符型
D. 整型、实型、字符型、逻辑型
满分:2 分
正确答案:C
4. 已知int a=4,b=5; ,这执行表达式a=a>b 后,变量a的值为
A. 0
B. 1
C. 4
D. 5
满分:2 分
正确答案:A
5. C语言中,函数返回值的类型是由
A. return语句中的表达式类型决定
B. 调用函数的主调函数类型决定
C. 调用函数时的临时类型决定
D. 定义函数时所指定的函数类型决定
满分:2 分
正确答案:D
6. 以下非法的赋值语句是
A. n=(i=2, i);
B. j ;
C. (i 1);
D. x=j>0;
满分:2 分 C
7. 设有定义int a=3,b=4,c=5; ,则以下表达式中,值为0的表达式是
A. a&&b
B. a<=b
C. a||b c&&b-c
D. !((a<b)&&!c||1)
满分:2 分 D
8. 设有int x=11;则表达式(x *1/3)的值是
A. 3
B. 4
C. 11
D. 12
满分:2 分 A
9. 结构化程序的3种基本控制结构是
A. if-else结构、while结构、for结构
B. 顺序结构、分支机构、循环结构
C. while结构、do-while结构、for结构
D. 以上三种都不对
满分:2 分 B
10. 设有定义语句:char str[][20]={"Hello","Beijing"},*p=str; 则
printf("%d\n",strlen(p+20)); 输出结果是
A. 0
B. 5
C. 7
D. 20
满分:2 分 C
二、简答题(共3 道试题,共30 分。
)V 1.
编程题:10个评委给出某选手打分,编程实现去掉一个最高分和一个最低分,求最后得分。
#include
int main()
{
int a[10],i,max,min;
float sum;
for(i=0;i<10;i++ )
{
scanf("%d",&a[i]);
}
max=a[0];
min=a[0];
for(i=1;i<=9;i++)
{
if(maxa[i])
min=a[i];
}
for(i=0;i<=9;i++)
{sum=sum+a[i];}
sum=(sum-max-min)/8;
printf("%f\n",sum);
}
}
2.
编程题:编写一个函数,将一个字符串(最多80个字符)中的大写字母变为小写字母,小写字母变为大写字母。
要求字符串的输入与输出在主函数中完成。
#include
void main()
{
inti;
char a[80];
gets(a);
puts(a);
for(i=0;i<80;i++)
if(a[i]>=65&&a[i]<=90)
a[i]=a[i]+32;
puts(a);
}
3.
编程题:编程任意输入两个实数a和b,计算下面函数的值,并输出y值。
#include
void main()
{
floata,b,y;
scanf(“%f,%f”,&a,&b);
if(a
void main()
{ int s,i;
for(s=0,i=1;i<5;i++,s+=i) ;
printf(“%d\n”,s);
}
答:14
满分:5 分
2. 读程序,写出程序执行结果#include
#include
int stre(char *s)
{ int num=0;
while(*(s+num)!=…\0‟)num++; return num;
}
void main()
{ char str[]="students",*p=str; printf(“%d\n”,stre(p));
}
答:students,8
满分:5 分
3.
读程序,写出程序执行结果
#include
void main()
{ int k=4,n=0;
for( ; n
int f( )
{ int s=1;
static int i=0;
s+=i; i++;
return s ;
void main()
{ int i,a=0;
for(i=0;i<3;i++) a+=f( );
printf("%d\n",a);
}
答:10
满分:5 分
5.
读程序,写出程序执行结果
#include
void main()
{ int a=0;
a+=(a=8);
printf(“%d\n”,a);
}
答:6
满分:5 分
6.
读程序,写出程序执行结果
#include
void main()
{ int i;
for (i=0; i<3; i++)
switch (i)
{ case 1: printf("%d ", i);
case 2: printf("%d ", i);
default : printf("%d ", i);
}
}
答:011122
满分:5 分
7.
读程序,写出程序执行结果#include
void main()
{ int s,t,a=-2,b=6;
s=t=1;
if(a>0) s=s+1;
if(a>b) t=s+t;
else if(a==b) t=5;
else t=2*s;
printf("t=%d ", t);
}
答:t=2
满分:5 分
8.
读程序,写出程序执行结果#include
void main()
{ int x=1,a=0,b=0;
switch(x)
{ case 0: b++;
case 1: a++;
case 2: a++;b++;
}
printf(“a=%d,b=%d\n”,a,b);
}
答:a=2,b=1
满分:5 分
9.
读程序,写出程序执行结果
#include
void main()
{ int i=0,a=0;
while( i<20 )
{ for(;;)
if((i%10)==0) break;
else i--;
i+=11;
a+=i;
}
printf("%d\n",a);
}
答:32
满分:5 分
10. 读程序,写出程序执行结果#include
void fun(char *w, int n)
{ char t, *s1, *s2;
s1=w;
s2=w+n-1;
while(s1
满分:5 分
-END-。