南开大学《高级语言程序设计1》期末考试试题(A卷) (2005.1)(有答案)
一、标记出如下程序中的语法错误,并简单说明出错原因(6分)。
#include﹤iostrem.h﹥
void main(){
int d[10], abc[6] = {2,4,0,-5,10,6,-8}, count=0;
for(i=0; i﹤10; i++)
if(d[i]=i) count++;
else count -;
cout﹤﹤” count=”﹤﹤count﹤﹤endl;
switch( d[i] ){
case 1,2: cout﹤﹤”1,2\n”; break;
case 3: cout﹤﹤”3\n”; break;
default: cout﹤﹤”others\n”;
}
1+2, 2+=3, count+=5;
}
二、选择题(14分)(共7题,每题2分)
1.以下程序的输出结果是_____。
#include﹤iostream.h﹥
main()
..........
资料预览图片: