for 练习 水仙花数

水仙花数

import java.util.Scanner;

public class forTest {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int count = 0;
		for(int i=100;i<=999;i++) {
			int a = i/100%10;
			int b = i/10%10;
			int c = i%10;
			if(Math.pow(a, 3)+Math.pow(b, 3)+Math.pow(c, 3)==i) {
				count++;
				System.out.println(i);
			}
		}
		System.out.println(count);
	}
}

倒三角

public class forTest {
	public static void main(String[] args) {
		int i=5;
		for (int x=0;x<5;x++) //外循环控制有几行
		{
			for(int y=1;y<i;y++)//内循环控制每列有几个
			{
				System.out.print("* ");
			}
			System.out.println();
			i--;
		}
		
		int j=1;
		for (int x=0;x<5;x++) //外循环控制有几行
		{
			for(int y=j;y<5;y++)//内循环控制每列有几个
			{
				System.out.print("* ");
			}
			System.out.println();
			j++;
		}
		
	}
}


* * * * 
* * * 
* * 
* 

* * * * 
* * * 
* * 
* 

12345
1234
123
12
1

public class forTest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int i=5;
		for (int x=0;x<=5;x++) //外循环控制有几行
		{
			for(int y=1;y<=i;y++)//内循环控制每列有几个
			{
				System.out.print(y);
			}
			System.out.println();
			i--;
		}

	}
}

54321
5432
543
54
5

public class forTest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int i=1;
		for (int x=1;x<=5;x++) //外循环控制有几行
		{
			for(int y=5;y>=i;y--)//内循环控制每列有几个
			{
				System.out.print(y);
			}
			System.out.println();
			i++;
		}
	}
}

54321
4321
321
21
1

public class forTest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		for(int i=5;i>0;i--) {
			for(int j=i;j>0;j--) {
				System.out.print(j);	
			}
			System.out.println();
		}
	}
}

九九乘法表

public class forTest6 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		for (int x=1; x<=9 ;x++ )
		{
			for (int y=1; y<=x ;y++ )
			{
				System.out.print(y+"*"+x+"="+y*x+"\t");
			}
			System.out.println();
		}
	}
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值