";
14. }
15. for(int i=start-1,n=1;i
16. if(n<=9){
17. s[i]=" "+n;
18. }
19. else{
20. s[i]=""+n;
21. }
22. n++;
23. }
24. for(int i=0;i25. if((i%7==0)&&(i>0)){
26. System.out.println();
27. }
28. System.out.print(s[i]+" ");
29. }
30. }
31. }
5.编写程序,找出给定字符串中所有以字符'a'开头的单词。
01. import java.util.regex.*;
02. public class MatcherTest {
03. public static void main(String[] args) {
04. //找出字符串中以字符'a'开头的所有单词
05. String s="A Java project contains source code and related files for "
06. +"building a Java program. It has an associated Java builder "
07. +"that can incrementally compile Java source files as they are changed.";
08. String regex="\\b[a|A][a-zA-Z]*\\b";
09. Pattern p=Pattern.compile(regex);
10. Matcher m=p.matcher(s);
11. System.out.println(s);
12. System.out.println("以字符a开头的所有单词为:");
13. while(m.find()) {
14. System.out.p