1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package 
上机练习;
 
public 
class 
A03class {
    
public 
String showA(
int 
rows, String ch) {
        
for 
(
int 
i = 
0
; i < rows; i++) {
            
for 
(
int 
j = 
0
; j <= i; j++) {
                
System.out.print(ch);
            
}
            
System.out.println();
        
}
        
return 
ch;
    
}
 
}
 
 
 
 
package 
上机练习;
 
import 
java.util.Scanner;
 
public 
class 
A03 {
 
    
public 
static 
void 
main(String[] args) {
        
// TODO Auto-generated method stub
        
A03class A03 = 
new 
A03class();
        
Scanner in = 
new 
Scanner(System.in);
        
System.out.println(
"请输入行数:"
);
        
int 
rows = in.nextInt();
        
System.out.println(
"请输入打印的图案:"
);
        
String ch = in.next();
        
A03.showA(rows, ch);
    
}
}