更多"下面的程序是求字符串的长度及每一个位置上的字符。请在每条横线处填写一条"的相关试题:
[简答题]下面程序的功能是输出字符串“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.________________));
}
}
[简答题]下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
______________________
public class SimpleCharInOut{
public static void main(String args[]){
char c=" ";
System.out.println("Enter a character please: ");
try{
____________________//接受用户键盘输入的字符并保存在变量c中
}
catch(________________________e){}
System.out.println("You’ve entered character "+c);
}
}
[填空题]下列函数从字符数组s[]中删除和c一样的字符,请在下面横线处填空。
void delete(s,c)
char s[],c;
{int i,j;
for(i=j=0;______;i++)
if(s[i]!=’c’)
s[j++]=s[i];
s[j]="/0";}
[填空题]在下面函数的横线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度 (不得使用系统提供的字符串处理函数)。
int GJetLen(char*str)if( 【8】 ) return 0;
else return 1+GetLen (str+1);
[填空题]在下面函数的横线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char*str)
if(______) return 0;
else return 1+GetLen(str+1);
[填空题]在下面函数的横线处填上适当的内容使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char *str
if ( 【6】 ) return 【17】 ;
else return 1+GetLen (str+1);
[填空题]
在下面函数的横线处填上适当的内容,使该函数能够利用递归方法求解字符串sb的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char*str)
{
it( () )return () ;
else return 1+GetLen(str+1);
}
[填空题]下面的程序用“冒泡”法将数组a中的10个整数按升序排列,请在横线处将程序补充完整。
public class Sun{
public static void main(String args[]){
int[]a={678,45,324,528,439,387,87,875,273,823};
int a1=0;
for(int i=0; i<=8;i++){
for(int j=______;j<=9;i++)
if(a[i]>=a[j]){
al=a[j];
a[j]=a[i];
a[i]=al;
}
}
for(int i=0;i<=9;i++)
System.out.println(a[i]);
}
}