System.out.println(" *");
System.out.println(" * *");
System.out.println(" * * *");
System.out.println(" * * * *");
...
够简单吧 , 不知楼主是何目的,是为了考查大家的基本功,还是为了向大家提供一个展示各自奇技淫巧的题目,还是闲着无事找乐子,
System.out.println(" * *");
System.out.println(" * * *");
System.out.println(" * * * *");
...
够简单吧 , 不知楼主是何目的,是为了考查大家的基本功,还是为了向大家提供一个展示各自奇技淫巧的题目,还是闲着无事找乐子,
final int n = 10;
for (int i = 0; i < n; ++i) {
for (int j = i; j < n; ++j) {
System.out.print(' ');
}
System.out.print('*');
for (int j = 1; j <= i; ++j) {
System.out.print(" *");
}
System.out.println();
}
}
}
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
jamesfancy()边城狂人(James Fancy) 的方法中规中矩,大部分人都会这么写。这个不是我的作业,我现在已经不用做作业了。只是想找一些巧妙的方法做一些小事。呵呵。
{
public static void main(String args[])
{
int MAX = 10;
for (int i = 0; i < MAX; i++) {
for (int j = 0; j < MAX * 2-1; j++) {
if (j >= MAX - i - 1 && j <= MAX + i - 1 && (MAX - i + j +1) % 2 == 0)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
好怀念的程序阿,只有两个for循环 :-p
不过他没有写出做法。
期待有人能写出来。
public class Test{
public static void main(String[] args){
String star = "* * * * * * * * * * * ";
String blank = " ";
for(int i=1,m=star.length(),n=blank.length();i<=n;i++){
System.out.print(blank.substring(i));
System.out.println(star.substring(m-i*2));
}
}
}
public class wonderSubstring{
public static void main(String[] args){
String star = "* * * * * * * * * * *";
String blank = " ";
for(int i=1,m=star.length(),n=blank.length();i<=n;i++){
System.out.print(blank.substring(i));
System.out.println(star.substring(m-i*2));
}
}
}
public static void test() {
String data[] = { " ", " *" };
int width = 1;
int output = 0;
final int n = 10;
for (int i = 1; width <= n; ++i) {
System.out.print(data[output]);
if (i + width == n) {
output = 1;
} else if (i == n) {
output = 0;
i = 0;
System.out.println();
++width;
}
}
} public static void main(String[] args) {
test();
}
}
* @(#) Test.java
* Create By James Fancy
*/
package jamesfancy;public class Test {
public static void test() {
String data[] = { " ", " *" };
int width = 1;
int output = 0;
final int n = 10;
for (int i = 0; width <= n; ++i) {
if (i + width == n) {
output = 1;
} else if (i == n) {
output = 0;
i = -1;
System.out.println();
++width;
}
if (i >= 0) {
System.out.print(data[output]);
}
}
} public static void main(String[] args) {
test();
}
}
System.out.println(" *\r\n * *\r\n * * *\r\n * * * *\r\n * * * * *\r\n * * * * * *\r\n * * * * * * *\r\n * * * * * * * *\r\n * * * * * * * * *\r\n * * * * * * * * * *\r\n");http://www.yi-dao.com
才是最强的答案
zhigangxie(易道模型)的程序不用动脑子都可以写啦,有什么用。
public static void main(String[] arg ) {
int n =10;
char[] line = new char[n];
StringBuffer result = new StringBuffer(((n+(n<<1)+1)*n)>>1));
while(n>0) {
line[--n]='*';
result.append(line).append(line,n,line.length-n-1).append('\n');
}
System.out.println(result);
}
}