3个回答
2013-10-13
展开全部
import java.util.Scanner;
public class Rhombus {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);//可键盘输入图形大小
System.out.print("请输入菱形大小:");
int length = sc.nextInt();//以下是输出空心菱形
for(int i=0;i<2*length-1;i++){
for(int j=0;j<2*length-1;j++){
if(j==length-1-i||-j==length-1-i||i==j-(length-1)||2*length-2-i==j-(length-1))
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}//下面是输出实心菱形
System.out.println("----------------");
for(int i=0;i<2*length-1;i++){
for(int j=0;j<2*length-1;j++){
if(j>=length-1-i&&-j<=length-1-i&&i>=j-(length-1)&&2*length-2-i>=j-(length-1))
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
public class Rhombus {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);//可键盘输入图形大小
System.out.print("请输入菱形大小:");
int length = sc.nextInt();//以下是输出空心菱形
for(int i=0;i<2*length-1;i++){
for(int j=0;j<2*length-1;j++){
if(j==length-1-i||-j==length-1-i||i==j-(length-1)||2*length-2-i==j-(length-1))
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}//下面是输出实心菱形
System.out.println("----------------");
for(int i=0;i<2*length-1;i++){
for(int j=0;j<2*length-1;j++){
if(j>=length-1-i&&-j<=length-1-i&&i>=j-(length-1)&&2*length-2-i>=j-(length-1))
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
2013-10-13
展开全部
public class Test {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 5 - i; j > 0; j--)
System.out.print(' ');
for (int m = 1; m <= 2 * i - 1; m++)
{
if(m==1||m==2*i-1)
System.out.print('*');
else
System.out.print(' ');
}
System.out.print('\n');
}
for (int n = 4; n >= 1; n--) {
for (int t = 5 - n; t > 0; t--)
System.out.print(' ');
for (int k = 1; k <= 2 * n - 1; k++)
{
if(k==1||k==2*n-1)
System.out.print('*');
else
System.out.print(' ');
}
System.out.print('\n');
}
}
}
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 5 - i; j > 0; j--)
System.out.print(' ');
for (int m = 1; m <= 2 * i - 1; m++)
{
if(m==1||m==2*i-1)
System.out.print('*');
else
System.out.print(' ');
}
System.out.print('\n');
}
for (int n = 4; n >= 1; n--) {
for (int t = 5 - n; t > 0; t--)
System.out.print(' ');
for (int k = 1; k <= 2 * n - 1; k++)
{
if(k==1||k==2*n-1)
System.out.print('*');
else
System.out.print(' ');
}
System.out.print('\n');
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-13
展开全部
......上面都有了.......最好是看得懂思路吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询