class Triangle2
{
	public static void main(String[] args){
		int x,y;
		for(x=1;x<=5;x+=1){
			for(y=1;y<=x+5;y+=1){
				System.out.print("\t");
					while(y==6-x){
						System.out.print("*");
						break;
					}
			}
		
				//System.out.print("\t");
				System.out.println("*");
				while(x==5){
					System.out.println("*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*");
					break;
				}
		}
	}
}

编译显示:

wKioL1c0A9rAUqIlAAAM5YPxa-U373.jpg

倒三角:

class Triangle
{
	public static void main(String[] args){
		int x,y;
		for(x=1;x<=5;x+=1){
			while(x==1){
				System.out.println("*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*"+"\t"+"*");
				break;
			}
			for(y=1;y<=10-x;y+=1){
				System.out.print("\t");
				while(y==x){
					System.out.print("*");
					break;
				}
			}
			while(x<5){
				System.out.println("*");
				break;
			}
		}
	}
}

编译显示:

wKiom1c0A56xkS2xAAAPYrnlYVo860.jpg