练习1-输出三角形与正方形“*”

记录Java学习。


public class HelloWorld{

public static void main(String[] args)
{
System.out.println("Hello World!");
}

}


乘法口诀

public class Multiply

{
public static void main(String[] args)
{
int i,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(i+"x"+j+"="+(i*j)+'\t');
}
System.out.println();
}
System.out.println("===============================================================================");
}

}


* 号形状输出:

public class Test01
{
public static void main(String[] args)
{
int i,j,k;
for(i=9;i>=1;i--)
{
for(j=1;j<=i;j++)
{

System.out.print("*"+" ");

}
System.out.println();
}
System.out.println();
int m=9;
int n=1;
do
{
System.out.println("* * * * * * * * *");
n++;
}
while (m>n);
System.out.println();
//int z=9;
int x,y;
for(x=1;x<=9;x++)
{
for(y=1;y<=9;y++)
{
System.out.print("*"+" ");
}
System.out.println();
}
}
}

你可能感兴趣的:(日常练习,Java基础)