A.0
B.1
C.5
D.10
第1题
A.4 10
B.1 2
C.22
D.24
第2题
B.1
C.15
D.16
第3题
A.876543
B.321678
C.1098765
D.345678
第4题
#include
int FindSubString(char* pch)
{
int count=0;
char* p1=pch;
while(*p1!=‘’)
{
if(*p1==p1[1]-1)
{
p1++
count++;
}
else
{
break;
}
}
int count2=count;
while(*p1!=‘’)
{
if(*p1!==p1[1]+1)
{
p1++;
count2--;
}
else
{
break;
}
if(count2==0)
return count;
return 0;
}
void ModifyString(char* pText)
{
char* p1=pText;
char* p2=p1;
while(*p1!=‘’)
{
int count=FindSubString(p1);
if(count>0)
{
*p2++=*p1;
sprintf(p2, “%I”, count);
while(*p2!= ‘’)
{
p2++;
}
p1+=count+count+1;
}
else
{
*p2++=*p1++;
}
}
}
void main(void)
{
char text[32]=“XYBCDCBABABA”;
ModifyString(text);
printf(text);
}
In the main() function, after ModifyString(text) is called, what’s the value of ‘text’?
第5题
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
public class SumAndAve{
public static void main(String args[ ]){
int count=0,sum=0,ave=0;
for(int i=1;i<=100;____________________)
if(_____________________)
continue;
else
{
___________________
sum=sum+i;
}
ave=sum/count;
System.out.println("sum="+sum);
System.out.println("ave="+ave);
}
}
第6题
A.1,2,3,4,
B.1,4,5,9,
C.1,0,7,0,
D.3,4,8,10
第7题
阅读以下说明和C函数,填充函数中的空缺,将解答填入答题纸的对应栏内。
【说明】
如果矩阵A中的元素A[i,j]满足条件:A[i,j]是第i行中值最小的元素,且又是第j列中值最大的元素,则称之为该矩阵的一个马鞍点。
一个矩阵可能存在多个马鞍点,也可能不存在马鞍点。下面的函数求解并输出一个矩阵中的所有马鞍点,最后返回该矩阵中马鞍点的个数。
【C函数】
Int findSaddle(int a[][N],int M),
{ /*a表示M行N列矩阵,N是宏定义符号常量量*/
int row,column,i,k;
int minElem;
int count=0;/*count用于记录矩阵中马鞍点的个数*/
for( row = 0;row< (1) ;row++) {
/*minElem用于表示第row行的最小元素值,其初值设为该行第0列的元素值*/
(2) ;
for( column = 1;column< (3) ;column++)
if( minElem> a[row][column]) {
minElem = a[row][column];
}
for(k=0;k<N;k++)
if(a[row][k]==minElem){
/术对第row行的每个最小元素,判断其是否为所在列的最大元素*/
for(i=0;i <M;i++)
if( (4) >minElem) break;
if(i>=(5) ){
printf("(%d,%d):%d\n",row,k,minElem);/*输出马鞍点*/
count++;
}/*if*/
}/*if*/
}/*for*/
return count,
}/*findSaddle*/
第8题
A.7,8
B.8,8
C.7,10
D.8,10
第9题
#include "stdio.h"
main()
{ int k[30]={12,324,45,6,768,98,21,34,453,456};
int count=0,i=0;
while(k[i])
{ if(k[i]%2==0||k[i]%5==0)count++;
i++; }
printf("%d,%d\n",count,i);}
则程序段的输出结果为
A.7,8
B.8,8
C.7,10
D.8,10
第10题
【说明】
本程序输出10000之内的所有完全数。完全数是指等于其所有因子和(包括1,但不包括这个数本身)的数。例如:6=1×2×3,6=1+2+3,则6是一个完全数。
【程序】
public class PerfectNum
{
Public static void main(String args[])
{
int count=1;
for(int i=1; i<10000; i++)
{
int y=0;
for(int j=1; j<i; j++)
if((1))
y=(2)
if((3))
{
System.out.print( (4) +String.valueOf('\t'));
(5)
If(count%3==0)
System.out.printin();
}
}
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!