码迷,mamicode.com
首页 > 其他好文 > 详细

1101作业:循环强化训练

时间:2016-11-01 21:15:41      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:div   indicator   训练   alt   code   lap   落地   http   乘法   

技术分享
 1 public class Homework01 {
 2     public static void main(String[] args) {
 3         int a=0,b=0,c=0;
 4         System.out.print("3位数的所有水仙花数为:");
 5         for (int i = 100; i < 1000; i++) {
 6             a = i / 100;// 百位
 7             b = i % 100 / 10;// 十位
 8             c = i % 100 % 10;// 个位
 9             if (i == a * a * a + b * b * b + c * c * c) {
10                 System.out.print(i + " ");
11             }
12         }
13     }
14 }
所有水仙花数
技术分享
 1 public class Homework02 {
 2     public static void main(String[] args) {
 3         double sum = 0, hight = 100;
 4         for (int i = 1; i <= 10; i++) {
 5             sum = sum + 2 * hight;
 6             hight /= 2;
 7             System.out.println("第"+i+"次落地时共经过" + sum + "米,落地后反弹"+hight+"米");
 8         }
 9     }
10 }
皮球反弹
技术分享
 1 public class Homework03 {
 2     public static void main(String[] args) {
 3         int x, y;
 4         System.out.print("\t1\t2\t3\t4\t5\t6\t7\t8\t9");
 5         for (x = 1; x < 10; x++) {
 6             System.out.print("\n" + x);
 7             for (y = 1; y <= x; y++) {
 8                 System.out.print("\t" + x + "*" + y + "=" + x * y);
 9             }
10 
11         }
12     }
13 }
九九乘法表
技术分享
 1 public class Homework04 {
 2     public static void main(String[] args) {
 3         for (int i = 0; i <=20; i++) {
 4             for (int j = 0; j <Math.abs(10-i); j++) {
 5                 System.out.print(" ");
 6             }
 7             for (int k = 0; k <=(10-Math.abs(i-10)); k++) {
 8                 System.out.print("* ");
 9             }
10             System.out.println();
11         }
12     }
13 }
画菱形

 

1101作业:循环强化训练

标签:div   indicator   训练   alt   code   lap   落地   http   乘法   

原文地址:http://www.cnblogs.com/woooooody/p/6020974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!