方形矩阵(5*5)
java:
public class Test {
public static void main(String[] args) {
int n = 5 ;
int m = 5 ;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
System.out.print("*");
}
System.out.println();
}
}
}
上三角矩阵:(5*5)
public class Test {
public static void main(String[] args) {
int n = 5 ;
int m = 5 ;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < i+1 ; j++){
System.out.print("*");
}
System.out.println();
}
}
}
下三角矩阵:(5*5)
public class Test {
public static void main(String[] args) {
int n = 5 ;
int m = 5 ;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m-i ; j++){
System.out.print("*");
}
System.out.println();
}
}
}
一点都不难,好好记,好好学。