用JAVA编程,输出图中的图形(就是那个数字倒三角)感谢感谢
1个回答
展开全部
public class Main{
public static String space = " ";
public static void main(String args[]){
int Arr[] = {1,3,5,7,9};
//int Arr[] = {1,3,5,7,9,11,13,15};
for (int i=0; i<Arr.length; i++) {
showInfo(Arr, i);
for (int j=0; j<Arr.length-i-1; j++) {
Arr[j] = Arr[j] + Arr[j+1];
}
}
}
public static void showInfo(int []data, int count) {
for (int i=0; i<count; i++) {
System.out.print(space);
}
for(int i=0; i<data.length-count;i++) {
System.out.print(space + data[i] + space);
}
System.out.println();
}
}
public static String space = " ";
public static void main(String args[]){
int Arr[] = {1,3,5,7,9};
//int Arr[] = {1,3,5,7,9,11,13,15};
for (int i=0; i<Arr.length; i++) {
showInfo(Arr, i);
for (int j=0; j<Arr.length-i-1; j++) {
Arr[j] = Arr[j] + Arr[j+1];
}
}
}
public static void showInfo(int []data, int count) {
for (int i=0; i<count; i++) {
System.out.print(space);
}
for(int i=0; i<data.length-count;i++) {
System.out.print(space + data[i] + space);
}
System.out.println();
}
}
追问
谢谢你谢谢你~我先看看,有不懂的我能再问你嘛
谢谢你~十分感谢~我懂了~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询