日期:2014-05-20 浏览次数:20742 次
public class test { public static void main(String[] args) { String[] s = new String[]{"*","**","***","**","*"} ; for (int i = 0; i < s.length ; i++) { System.out.println(s[i]) ; } } }
------解决方案--------------------
public class DrawXing {
public static void main(String[] args) {
String str = "*******";
String str1 = "*";
String str4 = " ";
String str2 = " ";
for (int i=0;i < 9;i++) {
if(i < 5){
String str3 = str2.substring(i);
System.out.println(str3 + str1);
str1 = str1 +"**";
}else {
System.out.println(str4+str.substring(2*(i-5)));
str4 = str4 + " ";
}
}
}
}
可以画出来,不知道是不是你说的情况
------解决方案--------------------
上面的str4 是一个空格,str2 是四个空格
------解决方案--------------------
public class sanjiao{
public static void main(String[] args){
int i=0;intj=0;
for(int i=;i<=4;i++){
for(int j=0;j<=2*i-1;j++){
System.out.println("*");
System.out.println("");
}
for(i=4;i>=1;i--){
for(j=1;j=2*i-3;j++)
System.out.ptintln("*");
System.out.println("");
}
}
}
------解决方案--------------------
public class Test { public static void main(String[] args) { myPrint(5); } private static void myPrint(int n){ //初始化输出数组 String[] strs = new String[n]; for(int i = 0;i < strs.length;i++){ if(i == 0) strs[i] = "*"; else strs[i] = strs[i - 1] + "*"; } //递增 System.out.println("递增"); for(int i = 0;i < strs.length;i++) System.out.println(strs[i]); //递减 System.out.println("递减"); for(int i = strs.length - 1;i >= 0;i--) System.out.println(strs[i]); } }
------解决方案--------------------
*
***
*****
[code=Java][/code]
public static void main(String[] args) {
triangle(5);
}
public static void triangle(int j){
String str1 = "*";
String str2 = "";
for(int i = 0;i < j-1;i++){