当前位置: 代码迷 >> Java相关 >> 关于for循环编程
  详细解决方案

关于for循环编程

热度:170   发布时间:2007-02-09 22:07:42.0
关于for循环编程
1.输入字母表中的所有大写字母.
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();
}
}
----------------解决方案--------------------------------------------------------
  相关解决方案