1 package com.bacasj; 2 3 public class Selectsort { 4 5 public static void main(String[] args) { 6 int[] arr = {99,2,3,5,1,56,6}; 7 for(int i = 0;i<arr.length;i++){ 8 for(int j= 1 ; j<arr.length;j++){ 9 if(arr[j-1]>arr[j]){ 10 int temp = arr[j]; 11 arr[j] = arr[j-1]; 12 arr[j-1] = temp; 13 } 14 } 15 } 16 System.out.println("升序: "); 17 for (int i = 0; i < arr.length; i++) { 18 System.out.print(arr[i]+" "); 19 } 20 } 21 }
1 package com.bacasj; 2 3 public class Blooensort { 4 5 public static void main(String[] args) { 6 int[] arr = {99,2,3,5,1,56,6}; 7 for(int i = 0;i<arr.length;i++){ 8 for(int j= 0 ; j<arr.length-1-i;j++){ 9 if(arr[j+1]>arr[j]){ 10 int temp = arr[j]; 11 arr[j] = arr[j+1]; 12 arr[j+1] = temp; 13 } 14 } 15 } 16 System.out.println("降序: "); 17 for (int i = 0; i < arr.length; i++) { 18 System.out.print(arr[i]+" "); 19 } 20 } 21 }
1 package com.bacasj; 2 3 public class Blooensort { 4 5 public static void main(String[] args) { 6 int[] arr = {99,2,3,5,1,56,6}; 7 for(int i = 0;i<arr.length;i++){ 8 for(int j= 0 ; j<arr.length-1-i;j++){ 9 if(arr[j+1]>arr[j]){ 10 int temp = arr[j]; 11 arr[j] = arr[j+1]; 12 arr[j+1] = temp; 13 } 14 } 15 } 16 System.out.println("降序: "); 17 for (int i = 0; i < arr.length; i++) { 18 System.out.print(arr[i]+" "); 19 } 20 } 21 }
1 package com.bacasj; 2 3 public class PersonArry { 4 5 public static void main(String[] args) { 6 person per[]=new person[3]; 7 per[0]=new person("AngleBabay",20,"女"); 8 per[1]=new person("Younggirlstage",22,"女"); 9 per[2]=new person("Pula",23,"女"); 10 for (int x=0;x<per.length;x++) 11 { 12 per[x].speak();//调用该方法获得具体信息 13 } 14 } 15 } 16 class person{ 17 private String name; 18 private int age; 19 String sex; 20 public person(String name,int age, String sex){ 21 this.name=name; 22 this.age=age; 23 this.sex=sex; 24 } 25 public void speak() 26 { 27 System.out.println("姓名: "+this.name+" 年龄: "+this.age + "性别:" + this.sex); 28 } 29 }
1 package com.ceo; 2 3 public class Fbonic { 4 public static void main(String[] args) { 5 6 int [] arr = new int[30]; 7 arr[0]=arr[1]=1; 8 for (int i = 2; i < arr.length; i++) { 9 arr[i] = arr[i-1] + arr[i-2];} 10 System.out.println("斐波那契数列的前30项如下所示:"); 11 for (int i = 0; i < arr.length; i++) { 12 if (i%6==0) 13 System.out.println(""); 14 System.out.print(arr[i]+" "); 15 } 16 } 17 }
1 package com.baidu; 2 3 import java.awt.Color; 4 import java.awt.Point; 5 import java.awt.event.KeyEvent; 6 7 import com.rupeng.game.GameCore; 8 9 /* 10 @author mawenqi 11 @version 2.0 12 @category 新增炸弹功能,精灵如果吃到炸弹立即死亡,游戏结束; 13 @category 新增游戏倒计时功能,倒计时60秒 14 @category 新增游戏胜利失败功能,吃完金币则胜利,吃到炸弹失败 15 */ 16 public class Coin2 implements Runnable { 17 public static void main(String[] args) { 18 GameCore.start(new Coin2()); 19 } 20 21 /* (non-Javadoc) 22 * @see java.lang.Runnable#run() 23 */ 24 @Override 25 public void run() { 26 // 设置窗体大小、标题、背景 27 GameCore.setGameSize(800, 340); 28 GameCore.setGameTitle("设计用键盘操作精灵玩的小游戏"); 29 GameCore.loadBgView("bg.jpg"); 30 GameCore.playSound("fir.mp3", true); 31 32 // 设置女精灵出现及出场位置 33 int spriteGirl = 0; 34 GameCore.createSprite(spriteGirl, "guizi"); 35 GameCore.playSpriteAnimate(spriteGirl, "run", true); 36 for (int i = 0; i < 700; i++) { 37 GameCore.setSpriteFlipX(spriteGirl, false); 38 GameCore.setSpritePosition(spriteGirl, 30 + i, 190); 39 GameCore.pause(10); 40 } 41 Point position = GameCore.getSpritePosition(spriteGirl); 42 int girlX = position.x; 43 int girlY = position.y; 44 for (int i = girlX; i > 30; i--) { 45 GameCore.setSpriteFlipX(spriteGirl, true); 46 GameCore.setSpritePosition(spriteGirl, i, girlY); 47 GameCore.pause(10); 48 49 // 使用数组放置8个金币的数量、横坐标、纵坐标 50 /*@SuppressWarnings("unused") 51 int[] coinNum = { 1,2,3,4,5,6,7,8}; 52 @SuppressWarnings("unused") 53 int[] coinXDate = {100,200,300,400,500,600,700,730}; 54 @SuppressWarnings("unused") 55 int[] coinYDate = {140,180,150,190,140,170,160,140};*/ 56 } 57 GameCore.pause(29000); 58 } 59 60 }