习题2-16.java
来自「JAVA用Java和XML建立试题库管理系统,试题库管理系统的设计」· Java 代码 · 共 45 行
JAVA
45 行
class tt
{
public static void main(String args[])
{
String ss="Returns the current capacity of the String buffer. ";
int n=ss.length();
StringBuffer sb=new StringBuffer(n);
int i=0,k,count=0;
int j=i;
while(true)
{
while(j<n&&!isA_Z(ss.charAt(j)))j++;
if(j<n)i=j;else break;
while(j<n&&isA_Z(ss.charAt(j)))j++;
if(j<n)
{
sb.append(ss.substring(i,j)+"\\");
count++;i=j;
}
else
{
sb.append(ss.substring(i)+"\\");
count++;break;
}
}
String w[]=new String[count];
for(k=0,i=0;k<count;k++)
{
j=sb.indexOf("\\",i);
w[k]=sb.substring(i,j);
i=j+1;
}
System.out.println(ss);
System.out.println(sb);
for(i=0;i<count;i++)
System.out.println(w[i]);
}
static boolean isA_Z(char ch)
{
if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
return true;
else
return false;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?