以下文字与答案无关
提示:有些试题内容 显示不完整,文字错误 或者 答案显示错误等问题,这是由于我们在扫描录入过程中 机器识别错误导致,人工逐条矫正总有遗漏,所以恳请 广大网友理解。
}
sum(int k)
{
int x=0;
return (x+=k);
}
程序运行后的输出结果是 ( )。
选项: A:55
B:45
C:15
D:10
">1.有以下程序#include <stdio.h>
void main()
{
int s,i,sum();
for (i=1;i<=10;i++)
s=sum(i);
printf("s=%d\n",s);
}
sum(int k)
{
int x=0;
return (x+=k);
}
程序运行后的输出结果是 ( )。
选项: A:55
B:45
C:15
D:10
}
选项: A:123
B:2412
C:246
D:248
">2.执行下列程序段后,屏幕输出结果是______。int i,s=2;
for(i=1;i<=3;i++)
{ s=s*i;
printf("%d",s);
}
选项: A:123
B:2412
C:246
D:248
}
选项: A:123
B:2412
C:246
D:248
">3.执行下列程序段后,屏幕输出结果是______。int i,s=2;
for(i=1;i<=3;i++)
{ s=s*i;
printf("%d",s);
}
选项: A:123
B:2412
C:246
D:248
sort(a,5);
printf("Now,the sequence is:\n");
for(i=0;i<n;i++)
printf("%d ",ai]);
}
void sort(int a],int n) //冒泡排序,从小到大排
{ int i, j;
int temp;
for( i = 1; i < n; i++ )
for (j = 0; j < n-i; j++ )
if (*(a+j) > *(a+j+1))
{ temp=*(a+j) ;
*(a+j)=*(a+j+1);
*(a+j+1)=temp;
}
}
">4.19. 分析下面的程序,如果输入25 66 44 12 99,写出运行结果。#include<stdio.h>
void sort(int a],int n);
int main(){
int a5];
int i;
for(i=0;i<5;i++)
scanf("%d",&ai]);
sort(a,5);
printf("Now,the sequence is:\n");
for(i=0;i<n;i++)
printf("%d ",ai]);
}
void sort(int a],int n) //冒泡排序,从小到大排
{ int i, j;
int temp;
for( i = 1; i < n; i++ )
for (j = 0; j < n-i; j++ )
if (*(a+j) > *(a+j+1))
{ temp=*(a+j) ;
*(a+j)=*(a+j+1);
*(a+j+1)=temp;
}
}
#include <stdio.h>
main( )
{ int i, a20], s, count;
s=count=0;
for(i=0;__ ; i++)
scanf(“%d”, &ai] );
for(i=0; i<20; i++)
{ if( ai]<0 ) continue ;
___ ;
count++;
}
printf(“s=%d\t count=%d\n”, s, count”);
}
var sum=0;
for(i=1; i<10; i++){
if(i%5==0)
break;
sum=sum+i;
}
选项: A:40
B:50
C:5
D:10
#include “stdio.h”
main( )
{
int i=0;
while(i<10)
{
if(i<1)continue;
if(i= =5)break;
i++;
}
}
选项: A:1
B:10
C:6
D:死循环,不能确定次数
}
程序运行的输出结果为(2分)
">14.请写出以下程序运行结果://环境 JDK 1.5及以上
public static void main(String args])
{
Set<Integer> set=new TreeSet<Integer>();
List<Integer> list=new ArrayList<Integer>();
for (int i=-3;i<3;i++)
{
set.add(i);
list.add(i);
}
for (int i=0;i<3;i++)
{
set.remove(i);
list.remove(i);
}
System.out.println(set+" "+list);
}
程序运行的输出结果为(2分)
}
若运行时依次输入:abcd、abba和abc三个字符串,则输出结果为________。
选项: A:A、abc B:B、abcd C:C、abca D:D、abba">17.以下程序中函数scmp的功能是返回形参指针s1和s2所指字符串中较小字符串的首地址#include<stdio.h>
#include<string.h>
char *scmp(char*s1,char*s2)
{
if(strcmp(s1,s2)<0)
return(s1);
else return(s2);
}
void main()
{
int i;
char string20],str3]20];
for(i=0;i<3;i++)
gets(stri]);
strcpy(string,scmp(str0],str1]));
/*库函数strcpy对字符串进行复制*/
strcpy(string,scmp(string,str2]));
printf("%s\n",string);
}
若运行时依次输入:abcd、abba和abc三个字符串,则输出结果为________。
选项: A:A、abc B:B、abcd C:C、abca D:D、abba/**********found**********/
if (find==__3__) printf("\nDon't found!\n");
}
main()
{ char xN]M]={"BASIC","C langwage","Java","QBASIC","Access"},strM];
int i;
printf("\nThe original string\n\n");
for(i=0;i<N;i++)puts(xi]); printf("\n");
printf("\nEnter a string for search : "); gets(str);
fun(x,str);
}
">19.第22套程序填空题
所属年份:2010.9;2011.3;
下列给定程序中,函数fun的功能是:在形参ss所指字符串数组中,查找含有形参substr所指子串的所有字符串,并输出,若没找到则输出相应信息。ss所指字符串数组中共有N个字符串,且串长小于M。程序中库函数strstr(s1,s2)的功能是在s1串中查找s2子串,若没有,函数值为0,若有,函数值为非0。
请在下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。
注意:部分源程序在文件BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
#include <stdio.h>
#include <string.h>
#define N 5
#define M 15
void fun(char (*ss)M], char *substr)
{ int i,find=0;
/**********found**********/
for(i=0; i< __1__ ; i++)
/**********found**********/
if( strstr(ssi], __2__) != NULL )
{ find=1; puts(ssi]); printf("\n"); }
/**********found**********/
if (find==__3__) printf("\nDon't found!\n");
}
main()
{ char xN]M]={"BASIC","C langwage","Java","QBASIC","Access"},strM];
int i;
printf("\nThe original string\n\n");
for(i=0;i<N;i++)puts(xi]); printf("\n");
printf("\nEnter a string for search : "); gets(str);
fun(x,str);
}