2.根据下面提示.编制程序.
结果为:1
23
345
4567
56789
小弟新手.希望各位帮忙解答下..谢谢了.
----------------解决方案--------------------------------------------------------
那个1和23也是对齐的.
1
23
345
4567
56789
----------------解决方案--------------------------------------------------------
[CODE]
/**
*
* @author hanfeng
*/
public class test {
/** Creates a new instance of test */
public test() {
}
public static void main(String [] args){
for(int i=1;i<6;i++){
for(int j=i;j<2*i;j++){
System.out.print(j);
}
System.out.println();
}
}
}
[/CODE]
----------------解决方案--------------------------------------------------------
谢谢...
我只想到了j=i
但是j<2*i死想想不出来又啥规律.谢了。
----------------解决方案--------------------------------------------------------
package pack;
public class test {
public static void main(String args[ ])
{
int i,j,m;
m=-1;
for(i=1;i<=5;i++)
{ //z=1;
System.out.println();
m+=2;
for(j=i;j<=m;j++)
{
System.out.print(j);
// j=i+j;
}
}
}
}
----------------解决方案--------------------------------------------------------
class test
{
public static void main(String []args)
{
for(int i=0;i<7;i++)
{
for(int j=0;j<i;j++)
{
System.out.println(j);
}
}
}
----------------解决方案--------------------------------------------------------
public class Test{
private int P=5;
public static void main(String[] args){
int i,j;
for(i=1;i<=5;i++){
for(j=i;j<=2*P-1;j++){
System.out.print(j);
}
SyStem.out.println();
}
}
----------------解决方案--------------------------------------------------------