/*使用一位数组解决 1 1 2 3 5 8 13 数列问题 斐波纳契数列 Fibonacci*/
package cn.GM; public class array { public static void main(String[] args) {
// TODO Auto-generated method stub
int arr[] = new int[30];
arr[0] = 1;
arr[1] = 1;
for (int i = 2; i < arr.length; i++) {
arr[i] = arr[i - 1] + arr[i - 2];
System.out.println(arr[i]);
} }
}

  

/* 选择法。从小到大排列 */
package cn.GM; public class yiwei { public static void main(String[] args) {
// TODO Auto-generated method stub
int[] arr = { 10, 347, 657, 38, 382, 75, 76, 56, 12344, 84654 };
/* 选择法。从小到大排列 */
for (int i = 0; i < arr.length - 1; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] > arr[j]) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
} }
for (int i : arr)
System.out.println(i);
} }

  

/*冒泡法。从小到大排列*/
package cn.GM; public class yiwweiM { public static void main(String[] args) {
// TODO Auto-generated method stub
int[] arr = {10, 347, 657, 38, 382, 75, 76, 56, 12344, 84654};
/*冒泡法。从小到大排列*/
for(int i = 0;i < arr.length;i++) {
for(int j = 0;j < arr.length - 1 -i;j++) {
if(arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
} }
for(int i : arr)
System.out.println(i); } }

  

/*人类对象数组——一堆人*/
package cn.GM; public class personarr { public static void main(String[] args) {
// TODO Auto-generated method stub
//建数组
person arr[] = new person[3];
arr[0] = new person("赵艺",20);
arr[1] = new person("欧阳娜娜",17);
arr[2] = new person("房祖名",32);
for(int x = 0;x < arr.length;x++)
arr[x].getInfo();
} } class person{
private String name;
private int age;
public person(String name,int age) {
this.name = name;
this.age = age;
}
public void getInfo() {
System.out.println("姓名:" + this.name + " 年龄:" + this.age); } }

  

最新文章

  1. 关于as3调用js报“null为空或不是对象”错误
  2. Android手机_软件安装目录
  3. Mongo DB 安装-及分布式集群部署(初稿)
  4. POJ 1159 Palindrome 最长公共子序列的问题
  5. 线性代数(高斯消元):JSOI2008 球形空间产生器sphere
  6. 关于android多点触控
  7. [Tool]利用Advanced Installer建立x86/x64在一起的安装程式
  8. Servlet程序开发-- 过滤器
  9. iOS开发之监听键盘高度的变化
  10. 利用Python实现一个感知机学习算法
  11. SQL---存储过程---sp_addextendedproperty表字段加描述
  12. 使用javascript中读取Xml文件做成的一个二级联动菜单
  13. (1)wr703n刷openwrt智能控制--配置wifi
  14. Jquery weui picker 支持label和value
  15. leetcode 203. Remove Linked List Elements 、83. Remove Duplicates from Sorted List 、82. Remove Duplicates from Sorted List II(剑指offer57 删除链表中重复的结点)
  16. 利用AMPScript获取Uber用户数据的访问权限
  17. CSS实现元素水平垂直居中
  18. 最新Linux系统Ubuntu16.04搭建HUSTOJ(LAMP环境)
  19. Activity启动模式(lauchMode)
  20. I2S接口工作原理

热门文章

  1. asp.net core 发布到iis session无法传递的问题
  2. 记录一个EF连接查询的异常:the entity or complex type &#39;x&#39; cannot be constructed in a linq to entities query
  3. java - day008 -final ,static ,访问控制符.
  4. MySQL 的安装与使用(一)
  5. flutter 解析json
  6. docker启动,重启,停止容器
  7. vertx的Actor模型实现
  8. 关于8.0.15版本的mysql下载与安装
  9. HttpListener 实现web服务器
  10. SpringBoot的Profiles根据开发环境和测试环境载入不同的配置文件