更多"在下面函数的横线处填上适当的内容使该函数能够利用递归方法求解字符串st"的相关试题:
[填空题]下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在横线处填上适当内容,实现该函数。
bool fun(char *str)
int i=0,j=0;
while(str[j])______;
for(j--;i<j && str [i]==str[j];i++,j--);
return i______j;
[填空题]在下面函数的画线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char*str)
if( (6) )return (7) ;
else return 1+GetLen(str+1);
[简答题]下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适当的语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class InputString
public static void main(String args[ ])
String stringname= new _______________ ("ABCDEFGH");
for(int i= _______________ i>=0;i--)
System.out.println(String.valueOf(stringname.________________));
[简答题]【说明】
在下面函数横线处填上适当的字句,使其输出结果为:
构造函数.
构造函数.
1,2
5,6
析构函数
析构函数.
【C++代码】
#include "iostream.h"
class AA
{ public;
AA(int i,int j)
{A=i; B=j;
cout<<"构造函数./n";
}
~AA( ){ (1) ;}
void print( );
private:
int A, B;
};
void AA∷print( )
{cout<<A<<","<<B<<endl;}
void main( )
{
AA *a1, *a2;
(2) =new AA(1, 2);
a2=new AA(5, 6);
(3) ;
a2->print( );
(4) a1;
(5) a2;
}
[简答题]【说明】
在下面函数横线处填上适当的字句,使其输出结果为:
构造函数.
构造函数.
1,2
5,6
析构函数
析构函数.
【C++代码】
#include "iostream.h"
class AA
public;
AA(int i,int j)
A=i; B=j;
cout<<"构造函数./n";
~AA( ) (1) ;
void print( );
private:
int A, B;
;
void AA∷print( )
cout<<A<<","<<B<<endl;
void main( )
AA *a1, *a2;
(2) =new AA(1, 2);
a2=new AA(5, 6);
(3) ;
a2->print( );
(4) a1;
(5) a2;
[单项选择]下列程序使用系统标准输入System.in从键盘获得输入字符串,请选择正确的一项填入下列程序的横线处。 import java.io.*; public class ex26 { public static void main(String args[]) { byte buffer[] = new byte[128]; int n; try { n = for(int i = 0; i < n; i++) System.out .print ( (char)buffer [i] ); catch (IOException e) { System.out.print (e); } } }
A. Systeiread(buffe
B. systeiread(buffe
C. Systeiread0
D. Systein(buffe
[填空题]下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在画线处填上适当内容,实现该函数。
bool fun(char*str)
int i:0,j=0;
while(str[j]) (6) ;
for(J--;i<j&&str[i]==str[J];i++,J--);
return i (7) J;
[填空题]在下面程序横线处填上适当内容,使得程序的输出为9876。
#include <iostream>
using namespace std;
template<class T>
void f( 【12】 )
{
T t;
for (int i=0;i<n/2;i++)
{
t=a Ii];
a [i]=a[n-1-i];
a [n-1-i]=t;
}
}
int main ( )
{
int x[]={6,7,8,9};
f(x,4);
for (int i=0;i<4;i++)
cout<<x[i];
cout<<end1;
return 0;
}
[简答题]在下面程序的横线处填上适当内容,完成类的定义。
class line;
class box
private:
int color;
int upx,upy;
int lowx,lowy;
public:
______
void set_color(int c)color=c;
void define_box(int x1,int y1,int x2,int y2)
upx=x1;upy=y1;lowx=x2;lowy=y2;
;
class line
private:
int color;
int startx,starty;
int endx,endy;
public:
friend int same_color(line l,box b);
void set_color(int c)color=c;
void define_line(______)
startx=x1;starry=y1;endx=x2;endy=y2;
;
int same_color(line l,box b)
if(l.color==b.color)return 1;
return 0;
[简答题]在下面程序横线处填上适当内容,使程序执行结果为:200_ _100。
#include<iostream.h>
template<class T>
T f(______)
if(______)
return x+y;
else
return x*y;
void main( )
cout<<f(10,20)<<"_ _"<<f(45.5,54.5)<<endl;
[填空题]在下面程序横线处填上适当内容,以使该程序执行结果为4.4。
#include<iostream>
using namespace std;
template<typename T>
T average(T*datA)
T s=0;
int i:0;
while(data[i])
【12】 ;
return s/(i+1);
int main( )
double x[]=2.5,4.5,6.5,5,0.0,12.5,23.3,18.5;
cout<<average(X);
return 0;
[简答题]在下面程序横线处填上适当内容,使程序执行结果为:40:15程序如下:
#include<iostream.h>
template<class T>
T func(T x,T y)
if(sizeof(T)= =8)
return______;
else
return______;
void main( )
cout<<func(8,5)<<":"<<func(5.0,10.0)<<endl;
int d;cin>>d;