] a = new int[N]; Scanner s = new Scanner(System.in); System.out.println(¡°ÇëÊäÈë10¸öÕûÊý£º¡±); for(int i=0; i a[i] = s.nextInt(); } System.out.print(¡°ÄãÊäÈëµÄÊý×éΪ£º¡±); for(int i=0; i System.out.print(a[i] + ¡± ¡°); } System.out.print(¡°\nÇëÊäÈëÏòºóÒƶ¯µÄλÊý£º¡±); int m = s.nextInt(); int[] b = new int[m]; for(int i=0; i b[i] = a[N-m+i]; } for(int i=N-1; i>=m; i¨C) { a[i] = a[i-m]; } for(int i=0; i a[i] = b[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 arr[i] = true; } 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 ¨C; } } index ++; if(index == n) { index = 0; } } for(int i=0; i if(arr[i] == true) { System.out.println(¡°ÔÅÅÔÚµÚ¡±+(i+1)+¡±Î»µÄÈËÁôÏÂÁË¡£¡±); } } }} ¡¾³ÌÐò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(¡°×Ö·û´®µÄ³¤¶ÈÊÇ£º¡±+str.length()); } } ¡¾³ÌÐò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(¡°ÏàÓ¦ÊýÁеĺÍΪ£º¡± + sum(n)); } 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] = ¡°matter¡±; s[1] = ¡°state¡±; s[2] = ¡°solid¡±; s[3] = ¡°liquid¡±; s[4] = ¡°gas¡±; for(int i=0; i for(int j=i+1; j if(compare(s[i], s[j]) == false) { temp = s[i]; s[i] = s[j]; s[j] = temp; } } } for(int i=0; i System.out.println(s[i]); } } static boolean compare(String s1, String s2) { boolean result = true; for(int i=0; i if(s1.charAt(i) > s2.charAt(i)) { result = false; break; } else if(s1.charAt(i) result = true; break; } else { 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(¡°ÔÓÐÌÒ×Ó ¡°+j+¡± ¸ö¡±); 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 (¡°809*¡±+i+¡±=¡±+¡±800*¡±+i+¡±+¡±+¡±9*¡±+i+¡±=¡±+b);} }} ¡¾³ÌÐò43¡¿ ÌâÄ¿£ºÇó0¡ª7ËùÄÜ×é³ÉµÄÆæÊý¸öÊý¡£ //×é³É1λÊýÊÇ4¸ö¡£ //×é³É2λÊýÊÇ7*4¸ö¡£ //×é³É3λÊýÊÇ7*8*4¸ö¡£ //×é³É4λÊýÊÇ7*8*8*4¸ö¡£ //¡¡ public class lianxi43 { public static void main (String[] args) { int sum=4; int j; System.out.println(¡°×é³É1λÊýÊÇ ¡°+sum+¡± ¸ö¡±); sum=sum*7; |