}
   for(int i=0; i System.out.print(\位移后的数组是:\   for(int i=0; i     System.out.print(a[i] + \   } } }  【程序37】     题目:有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来第几号的那位。    import java.util.Scanner; public class lianxi37 {  public static void main(String[] args) {    Scanner s = new Scanner(System.in);     System.out.print(\请输入排成一圈的人数:\   int n = s.nextInt();     boolean[] arr = new boolean[n];    for(int i=0; i    int leftCount = n;    int countNum = 0;    int index = 0;     while(leftCount > 1) {     if(arr[index] == true) {      countNum ++;        if(countNum == 3) {       countNum =0;        arr[index] = false;       leftCount --;      }     }       index ++;       if(index == n) {      index = 0;     }    }      for(int i=0; i      System.out.println(\原排在第\位的人留下了。\    }     } } }  【程序38】     题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。    /*??????  *??题目意思似乎不能用length()函数     */ import java.util.*; public class lianxi38 {  public static void main(String[] args) {     Scanner s = new Scanner(System.in);      System.out.println(\请输入一个字符串:\    String str = s.nextLine();       System.out.println(\字符串的长度是:\    }     }   【程序39】     题目:编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n(利用指针函数)    //没有利用指针函数 import java.util.*; public class lianxi39 {  public static void main(String[] args) {     Scanner s = new Scanner(System.in);      System.out.print(\请输入一个正整数 n= \    int n = s.nextInt();      System.out.println(\相应数列的和为:\   }  public static double sum(int n) {     double res = 0;     if(n % 2 == 0) {       for(int i=2; i<=n; i+=2) {       res += (double)1 / i;      }       } else {       for(int i=1; i<=n; i+=2) {       res += (double)1 / i ;      }     }      return res; } }   【程序40】     题目:字符串排序。     public class lianxi40 {  public static void main(String[] args) {    int N=5;     String temp = null;     String[] s = new String[N];    s[0] = \   s[1] = \   s[2] = \   s[3] = \   s[4] = \    for(int i=0; i      if(compare(s[i], s[j]) == false) {       temp = s[i];       s[i] = s[j];       s[j] = temp;      }     }    }      for(int i=0; i static boolean compare(String s1, String s2) {    boolean result = true;     for(int i=0; i     } else if(s1.charAt(i)       if(s1.length() < s2.length()) {       result = true;      } else {        result = false;      }     }    }     return result; } }  【程序41】     题目:海滩上有一堆桃子,五只猴子来分。第一只猴子把这堆桃子凭据分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了一个,它同样把多的一个扔入海中,拿走了一份,第三、第四、第五只猴子都是这样做的,问海滩上原来最少有多少个桃子?    public class lianxi41 {   public static void main (String[] args) {  int i,m,j=0,k,count;  for(i=4;i<10000;i+=4)     { count=0;       m=i;        for(k=0;k<5;k++)          {            j=i/4*5+1;           i=j;            if(j%4==0)              count++;              else break;         }      i=m;  if(count==4)   {System.out.println(\原有桃子 \个\break;}  }  }  }   【程序42】     题目:809*??=800*??+9*??+1    其中??代表的两位数,8*??的结果为两位数,9*??的结果为3位数。求??代表的两位数,及809*??后的结果。     //题目错了!809x=800x+9x+1 这样的方程无解。去掉那个1就有解了。 public class lianxi42 {   public static void main (String[] args) {  int a=809,b,i; for(i=10;i<13;i++) {b=i*a ;  if(8*i<100&&9*i>=100)  System.out.println (\} }   【程序43】     题目:求0—7所能组成的奇数个数。    //组成1位数是4个。 //组成2位数是7*4个。 //组成3位数是7*8*4个。 //组成4位数是7*8*8*4个。