}
【供选择的答案】 (1) [A] mark>=0
[C] mark<=0 (2) [A] else if(mark>=60)
[C] else (mark>=60) (3) [A] else (mark<60)
[C] if(mark>0) (4) [A] scanf(\”,mark);
[C] ;
[B] mark>0
[D] mark<0 [B] if(mark>=60) [D] if(mark<90) [B] else
[D] else if(mark<=60) [B] scanf(\”,&mark); [D] mark=getchar();
试题2(每小题3分,共12分)
阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序说明】 求1-999之间所有满足各位数字的立方和等于它本身的数。例如153的各位数字的立方和是13+53+33=153 运行示例: 1 153 370 371 407
【程序】
#include
{ int digit,j,sum,x; for(j=1;j<1000;j++){ ___(5)___
___(6)___ do{
___(7)___
sum=sum+digit*digit*digit; x=x/10;
}while(___(8)___);
if(sum= =j) printf(“%d ”,sum); } }
【供选择的答案】 (5) [A] sum=0; (7) [A] digit=x/10; (8) [A] x= =0
[B] sum=1; [B] ; [B] j!=0
[C] sum=j; [C] digit=x; [C] j= =0
[D] ; [D] digit=x; [D] x!=0
(6) [A] x=1; [B] x=j; [C] ; [D] x=sum;
试题3(每小题3分,共12分)
阅读下列程序说明和程序,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序说明】
输入10个整数,将它们从大到小排序后输出。
21
运行示例:
Enter 10 integers:10 98 -9 3 6 9 100 -1 0 2 After sorted:100 98 10 9 6 3 2 0 -1 -9 【程序】
#include
___(9)___
void sort(___(10)___) { int i,index,k,t;
for(k=0;k for(i=k+1;i if(a[i]>a[index]) index=i; ___(11)___ } } void swap(int *x,int *y) { int t; t=*x;*x=*y;*y=t; } main() { int i,a[10]; printf(“Enter 10 integers:”); for(i=0;i<10;i++) scanf(“%d”,&a[i]); ___(12)___ printf(“After sorted:”); for(i=0;i<10;i++) printf(“%d ”,a[i]); printf(“\\n”); } 【供选择的答案】 (9) [A] void swap(int *x,int *y) [B] ; [C] void swap(int *x,int *y); [D] void swap(int *x, *y) (10) [A] int &a,int n [C] int *a,int n (11) [A] swap(*a[index],*a[k]) [C] swap(index,k) [B] int *a,int *n [D] int a,int *n [B] swap(a[index],a[k]) [D] swap(&a[index],&a[k]) (12) [A] sort(a) [B] sort(a[10]) [C] sort(a[],10) [D] sort(a,10) 试题4(每小题3分,共12分) 阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序】 22 程序1 #include { int j,k,s1,s2; s1=s2=0; for(j=1;j<=5;j++){ s1++; for(k=1;k<=j;k++) s2++; } printf(“%d %d”,s1,s2); }. 程序2 #include { int j,k,s1,s2; s1=0; for(j=1;j<=5;j++){ s1++; for(k=1,s2=0;k<=j;k++) s2++; } printf(“%d %d”,s1,s2); }. 程序3 #include { int j,k,s1,s2; s1=0; for(j=1;j<=5;j++){ s1++; for(k=1;k<=j;k++,s2=0) s2++; } printf(“%d %d”,s1,s2); }. 程序4 #include { int j,k,s1,s2; s1=s2=0; for(j=1;j<=5;j++,s1=0){ s1++; for(k=1;k<=j;k++) s2++; } printf(“%d %d”,s1,s2); }. 【供选择的答案】 23 (13) 程序1运行时,输出: [A] 0 15 [B]5 0 (14) 程序2运行时,输出: [A] 0 15 [B]5 0 (15) 程序3运行时,输出: [A] 0 15 [B]5 0 (16) 程序4运行时,输出: [A] 0 15 [B]5 0 [C]5 5 [C]5 5 [C]5 5 [C]5 5 [D] 5 15 [D] 5 15 [D] 5 15 [D] 5 15 试题5(每小题3分,共12分) 阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序】 程序1 #include { int i,m=15,y=-1; for(i=2;i<=m/2;i++) if(m%i= =0) y=0; else y=1; printf(“%d”,y); } 程序2 #include { int i,m=15,y=-1; for(i=2;i<=m/2;i++) if(m%i= =0) {y=0;break;} printf(“%d”,y); } 程序3 #include { int i,m=15,y=-1; for(i=2;i<=m/2;i++) if(m%i= =0) break; if(i>m/2) y=1; else y=0; printf(“%d”,y); } 程序4 #include { int i,m=15,y=-1; for(i=2;i<=m/2;i++) if(m%i= =0) {break;y=0;} printf(“%d”,y); 24 } 【供选择的答案】 (17) 程序1运行时,输出: [A]1 [B]0 (18) 程序2运行时,输出: [A]15 [B]0 (19) 程序3运行时,输出: [A]-1 [B]1 (20) 程序4运行时,输出: [A]0 [B]15 [C]15 [C]-1 [C]0 [C]1 [D]-1 [D]1 [D]15 [D]-1 试题6(每小题3分,共12分) 阅读下列程序并回答问题,在每小题提供的若干可选答案中,挑选一个正确答案。 【程序】 #include char ch,a[10],*s[10]={“one”,”two”,”three”,”four”}; k=0; while((ch=getchar())!=?\\n?&&k<9) if(ch>=?5?&&ch<=?8?) a[k++]=ch; a[k]=?\\0?; for(k=0;a[k]!=?\\0?;k++) printf(“%ds”,s[(?9?-a[k])-1]); } 【供选择的答案】 (21) 程序运行时,输入5678,输出: [A] two three [C] one four three (22) 程序运行时,输入8561#,输出: [A] two three [C] one four three (23) 程序运行时,输入7902#,输出: [A] two three [C] one four three (24) 程序运行时,输入7633#,输出: [A] two three [C] one four three [B] two [D] four three two one [B] two [D] four three two one [B] two [D] four three two one [B] two [D] four three two one 试题7(28分) 25