浙大14年C语言专题试卷-英文
更新时间:2024-01-21 16:50:01 阅读量: 教育文库 文档下载
- 浙大c语言邀请码推荐度:
- 相关推荐
浙江大学2014–2015学年冬季学期
《程序设计基础》课程期末考试试卷
课程号: 211Z0040 , 开课学院: 计算机学院__ 考试试卷:√A卷、B卷(请在选定项上打√)
考试形式:√闭、开卷(请在选定项上打√),允许带 ∕入场 考试日期: 2015 年 01 月 28 日,考试时间: 120 分钟
诚信考试,沉着应考,杜绝违纪.
考生姓名: 学号: 所属院系: _ (注意:答题内容必须写在答题卷上,写在本试题卷上无效)
Section 1: Single Choice(2 marks for each item, total 20 marks)
1. Which one below is NOT a valid identifier in the C programming language? _____.
A. printf B. _ever C. “char” D. true
2. Given a, b and c as three double variables, which one below is NOT equivalent to a/b/c? _____. A. (a/b)/c B. a/(b/c) C. a/(b*c) D. a/c/b 3. Which function header is NOT correct? _____.
A. void f(void) B. void f(int i) C. void f(int i,j) D. void f(int i, int j) 4. Given the code below, what will be the value of i after the loop? _____.
int i;
while ( i<10 ) i++; A. 10 B. 11 C. 9 D. None of above.
5. Given the declarations: int a[5], *p=a; which expression is equivalent to the
expression p+1 ? _____.
B. &a+1 A.a[1]
y after executing y=(*p)++; ? _____.
A.y=1 B.y=2
C.a+1
D. p[2]-1
6. For the declarations: int a[]={1,2,3,4,5},*p=a+1, y; what will be the value of variable
C.y=3
D. Syntax error.
7. For the declarations: int *p[2], n[5]; which assignment expression is correct? _____ .
B. p=&n[0] D. p[0]=n++ A.p=n C.p[0]=n
8. Given the following code fragment, the loop condition str[i]!=’\\0’ could be replaced by
which choice? ______. char str[20]=”hello, world”;
for (i = 0; str[i] != ?\\0?; i++) putchar(str[i]); A.str[i]
B.i < 20
C.!(str[i] = ?\\0?)
D.i <= 20
“Fundamentals of Programming” Term Examination Paper, Jan 28, 2015 1 / 8
9. Which function-calling statement could be used, to open a text file entitled “abc.txt”
and located in the folder “user” within D diskette, which is opened for the reading and writing operation? ______. A.fopen(\C. fopen(\A.int *p[5]; scanf(\C.int n[10], *p=n; scanf(\
B. fopen(\D.fopen(\B.int *p; scanf(\
D.int n, *p; *p= &n; scanf(\
10. In the following code fragments, which item is completely correct? ______.
Section 2: Fill in the blanks(2 marks for each item, total 30 marks)
1. The value of expression 3/6*2.0 is ________. 2. The value of expression '9'-'0' is _______. 3. Given:
char c = 255; printf(\
The output should be: _______. 4. Given:
int b=50;
if ( 1
5. The following code fragment will print out _____________________________.
void swap(int *pa, *pb) {
int *t = pa; pa = pb; pb = t; }
int a = 1, b = 2; swap(&a, &b); printf(“%d#%d#”, a, b);
6. The output of the code below is ________.
char *s=”abc”;
while ( *s++ ) if (*s) putchar(*s-1);
7. Given the declaration: char *s;, write a statement which could be used to allocate 10
bytes from the system and assign the first address to the variable s _____________. 8. Try to use the function-call of fscanf, to replace the function-call of scanf(”%d”,&m);
______________________________________________.
9. Given the declaration: char *s; , write an expression without any function-calling,
which is equivalent to the expression strlen(s)==1 _____________________. 10. Given the declaration: int a[3][2]={1,2,3,4,5,6}; what is the value of expression
(a[1]+1)[0] ?____________.
“Fundamentals of Programming” Term Examination Paper, Jan 28, 2015 2 / 8
11. The value of expression !*(“2015-01-28”+5) is ______________. 12. The output of the code below is ________.
char x[ ]=”hello,world\\012345”; printf(”%d#%d#”,sizeof(x),strlen(x)); 13. The output of the code below is ________.
char *a[3]={\ printf(\printf(\
14. Given the declarations: FILE *infp, *outfp;, write a statement: it is used to write a
letter, which is read from a file pointer infp, into the file pointer outfp, which points to an output file. ________________________________________________________. 15. Given the declaration: char s[10]=”12345678”; what will be the value of strlen(s)
after executing strcpy(s+2,s+5); ________.
Section 3: Read each of the following programs and answer questions (5marks for each item, total 30 marks)
1. What is the output of the following program? _____________________________.
#include
void swap(int *a, int b) {
int m, *n;
n=&m; *n=*a; *a=b; b=*n; }
int main() {
int x=8,y=1; swap(&x,y); printf(\}
2. When input: 123, what is the output of the following program_______________.
#include
int f(char s[], int b) {
int i=0, n=0;
“Fundamentals of Programming” Term Examination Paper, Jan 28, 2015 3 / 8
while (s[i]!=?\\0?) { n=n*b+s[i]-'0'; i++; }
return n; }
int main() {
char s[20]; int n;
scanf(\
printf(\}
3. When the following program?s input is
ing
This is a long test string
the output of the program is __________.
#include
int main() {
char s[100], t[100], ch, *p;
int count, i;
gets(s); gets(t); for (i = 0; i < strlen(s); i++) { count=0; p = t; while (*p != '\\0') {
if (*p == s[i]) count++;
p++; } printf(\ }
}
4. The output of the following program?s is ____________.
#include
void fun(char *s[], int n) {
char *t; int i,j;
“Fundamentals of Programming” Term Examination Paper, Jan 28, 2015
4 / 8 for (i=0; i if (strlen(s[i])> strlen(s[j])) { t=s[i]; s[i]=s[j]; s[j]=t; } } int main() { char *s[]={\ “has reached”, “top level\ fun(s,4); printf(\ } 5. The following program will print out ____________. #include void p1(int v[]) { int i,j,temp; for (i=1; i<4; i++) for (j=i-1; j>=0&&v[j] v[j]=v[j+1]; v[j+1]=temp; } } void p2(int v1[], int v2[]) { int i=0, j=0; while (i<4 && j<4) { if (v1[i]>v2[j]) { printf(\ } else { printf(\ } } while (i<4) printf(\ while (j<4) printf(\} main() { int a[2][4]={{5,3,7,2},{4,1,8,6}}; p1(a[0]); p1(a[1]); p2(a[0],a[1]); } “Fundamentals of Programming” Term Examination Paper, Jan 28, 2015 5 / 8 6. When input: 8 1 2 3 4 5 6 7 8, the following program will print out ____________. #include void F1(int *a, int n) { int t, *b = a + n - 1; while (a < b) { t = *a; *a = *b; *b = t; a++; b--; } } void F2(int *a, int n) { int i,t; if (n <= 1) return; for (i = 0; i < n/2; i++){ t = *(a + i); *(a + i) = *(a + n - 1 - i); *(a + n - 1 - i) = t; } } int main(void ) { int i, n, *a; scanf(\ if ((a = (int*)malloc(n*sizeof(int))) == NULL) return 2; for (i = 0; i for (i = 0; i < n; i++) printf(\ return 0; } Section 4: According to the specification, complete each program (2 marks for each blank, total 20 marks) 1. There is an increasing ordered (升序) character list in a text file in.txt. The following program read in this list, calculate the number of duplicates(重复) and write each character and its frequency of occurrence (>1) (大于1的出现次数) into the file out.txt. For example, if the in.txt contains “abbcdddddddddddde”, the list “ab2cd12e” will be written into out.txt. “Fundamentals of Programming” Term Examination Paper, Jan 28, 2015 6 / 8 #include main() { FILE *fp1, *fp2; char last, c; int count=0; fp1=fopen(\ fp2=fopen(\ if (_______(1)_______) return (0); last='\\0'; while (______(2)_____) { count++; if (c!=last) { if (count>1) _______(3)______; count=0; _______(4)______; last=___(5)____; } } fclose(fp1); fclose(fp2); } 2. Function strncat(char *ret, char *s2, int n) copy at most n characters from s2 to ret. The output of the following program is: WooMan GoodWoMan Please complete the program. #include char *strncat(char *ret, char *s2, int n) { char *s1=ret; if (n>0) { while (_____(6)____); s1--; while (*s1++=_____(7)____) { if (--n>0) continue; *s1=_____(8)_____; break; } return ret; } else { return s1; } } “Fundamentals of Programming” Term Examination Paper, Jan 28, 2015 7 / 8 main() { char s[100]=”Good”; char t1[100]=”Woo”; char t2[100]=”Manager”; strncat(____(9)_____); printf(“%s\\n”, t1); strncat(____(10)_____); printf(“%s\\n”, s); } “Fundamentals of Programming” Term Examination Paper, Jan 28, 2015 8 / 8
正在阅读:
浙大14年C语言专题试卷-英文01-21
2018-2023年中国二氧化碳气体保护焊行业市场竞争现状分析与未来04-01
心情短语之以实用主义为导向的我国《刑法》第二十八条重构论12-25
1999年—2002年考研英语真题答案09-19
中建史有答案的05-23
新版PEP英语三年级上册单词、句子、语法、练习汇总807-29
观念一转,天高地远11-03
小学音乐期末考核标准01-10
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 英文
- 浙大
- 试卷
- 语言
- 专题
- 平面水性涂料之无机涂料
- 牧场物语双子村攻略食谱食材
- GRE填空教程分析(1-10)最新完整版20110402
- 名词解释以及问答题
- 浙江计算机三级单片机最全 不用找了 10财富值绝对值 - 图文
- 昆仑通态脚本开发函数
- 笔记本电脑维护常识
- 女命八字带伤官的解释
- 2015年一级建造师建筑工程实务强记重点及培训
- 神经干复合动作电位的记录和观察
- Book 8 Unit 2导学案
- 小学作文主教学研讨会发言材料:让农村孩子爱上作文
- 现代汉语下册重点(含例) - 图文
- 英国文学史及复习概要
- 王海霖—稿件投稿及审阅系统文献综述(修改2)
- 市场营销第1-3章练习题
- 体育与健康课程标准(三学期课程标准)
- 苏州市吴中区太湖水域“4·4”重大水上交通事故调查报告
- 英语中不能用于被动语态的动词都有哪些
- 2018仁爱英语7年级上册Unint1Topic3学科讲义