这个是作业吧哈哈!!
用双循环做的!
public static void main( String[] arg ){
int n = 4;
for(int i = 0; i < n; i++){
int m = i + 1;
for(int j=n-i-1;j>0;j--){
System.out.print(" ");
}
while(m > 0){
System.out.print("* ");
m--;
}
System.out.print("\n");
}
}
import java.util.Scanner;
public class Test050 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for(int i = 0; i < n; i++){
int count = i + 1;
for(int j = 0; j < n - i - 1; j++){
System.out.print(" ");
}
for(; count > 0; count--){
System.out.print("* ");
}
System.out.println();
}
}
}
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
printS(5);
}
public static void printS(int n) {
int a = n + n - 1;
for (int i=1; i<=n; i++) {
int m = i + i -1;
for (int j=1; j<=(a-m)/2; j++) {
System.out.print(" ");
}
for (int k=1; k<=m; k++) {
System.out.print("*");
}
System.out.println();
}
}
}
import java.util.Scanner;
public class Play {
public static void main(String[] args){
System.out.println("请输入数字:");
Scanner s = new Scanner(System.in);
int line = s.nextInt();
for(int i=0;i
int empty = line-1-i;
while(empty>0){
System.out.print(" ");
empty--;
}
while(star>=0){
System.out.print("* ");
star--;
}
System.out.println("");
}
}
}