67,513
社区成员
发帖
与我相关
我的任务
分享
package org.shanghai.com.shape;
public class DengYao {
// /**
// * 使用"*",输出等腰三角形
// *
// * @param args
// */
// public static void main(String[] args) {
// for (int i = 1; i <= 4; i++) {
// for (int j = 1; j <= 5 - i; j++) {
// System.out.print(" ");
// }
// for (int j = 1; j <= i * 2 - 1; j++) {
// System.out.print("*");
// }
// System.out.println();
// }
// }
// }
/**
* 倒直角三角形
*/
public static void main(String[] args) {
int x, y;
for (x = 0; x <= 4; x++) {
for (y = 0; y <= 4 - Math.abs(x); y++) {
System.out.print("*");
}
System.out.println();
}
}
}
package org.shanghai.com.shape;
import java.util.Scanner;
public class Rhombus {
/**
* 输入"*"的个数,打出空心菱形
*
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入菱形的边长:");
int x = sc.nextInt();
for (int i = -(x - 1); i <= (x - 1); i++) {
for (int j = 1; j <= 2 * x - 1; j++) {
if (j == Math.abs(i) + 1 || j == 2 * x - 1 - Math.abs(i)) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
package org.shanghai.com.shape;
/**
* 实心菱形
*/
public class Rhombus1 {
public static void main(String[] args) {
int x, y, z;
for (x = -4; x <= 4; x++) {
for (z = 1; z <= Math.abs(x); z++) {
System.out.print(" ");
}
for (y = 1; y <= 9 - Math.abs(x) * 2; y++) {
System.out.print("*");
}
System.out.println();
}
}
}
package org.shanghai.com.shape;
public class small_small_nine {
public static void main(String args[]) {
// int i;
// int a;
// for (i = 1; i < 10; i++) {
// for (a = 1; a <= i; a++) {
// System.out.print(i + "*" + a + "=" + (i * a));
// System.out.print(" ");
// }
// System.out.println(" ");
// }
// for (int i = 1; i < 10; i++) {
// for (int k = 1; k <= i; k++) {
// if (i == k) {
// System.out.println(i + "*" + k + "=" + i * k);
// } else {
// System.out.print(k + "*" + i + "=" + i * k + "\t");
// }
// }
// }
//
// for (int i = 0; i < 10; i++) {
// for (int j = 0; j < 10; j++) {
// if (j < 9 - i) {
// System.out.print(" ");
// } else {
// System.out.print("*");
// }
// }
// System.out.println();
// }
// for (int i = 1, j = 1; j <= 9; i++) {
// System.out.print(i + "*" + j + "=" + i * j + " ");
// if(i==j)
// {
// i=0;
// j++;
// System.out.println();
// }
// }
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
if (i * j < 10) {
System.out.print(j + "x" + i + "=" + i * j + " ");
} else {
System.out.print(j + "x" + i + "=" + i * j + " ");
}
}
System.out.println(" ");
}
}
}
package org.shanghai.com.shape;
public class Supare {
/**
* 使用*打印出正方形
*/
public static void main(String[] args) {
for (int j = 1; j <= 4; j++) {
for (int i = 1; i <= 5; i++) {
System.out.print("*");
}
System.out.println();
}
}
}
package org.shanghai.com.shape;
public class Supare {
/**
* 使用*打印出正方形
*/
public static void main(String[] args) {
for (int j = 1; j <= 4; j++) {
for (int i = 1; i <= 5; i++) {
System.out.print("*");
}
System.out.println();
}
}
}
package org.shanghai.com.shape;
public class Supare {
/**
* 使用*打印出正方形
*/
public static void main(String[] args) {
for (int j = 1; j <= 4; j++) {
for (int i = 1; i <= 5; i++) {
System.out.print("*");
}
System.out.println();
}
}
}
package org.shanghai.com.shape;
public class Parallelogram {
/**
* @param args
*/
public static void main(String[] args) {
for (int j = 1; j <= 4; j++) {
for (int i = 0; i < j; i++) {
System.out.print(" ");
}
for (int i = 1; i <= 5; i++) {
System.out.print("*");
}
System.out.println();
}
}
}