怎么运用从键盘输出语句!(菜鸟级)
怎么运用从键盘输出语句!
public class test
{
public static void main(String[] args)
{
int i,j,n;
n=7; //怎么样才能运用JAVA的SYSTEM.IN
for(j=1;j<=7;j++)
{
for(i=1;i<=n;i++)
System.out.print("1");
System.out.print("\n");
n--;
}
}
}
import
import
import
public class test
{
public static void main(String[] args)
{
int n = 0;
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
System.out.println("Please input an integer value, that is larger than 0.");
System.out.print("n = ");
try
{
String input = reader.readLine();
n = Integer.parseInt( input );
}
catch ( IOException e )
{
e.printStackTrace();
}
if(n>0)
{
for(int j=0;j<n;j++)
{
for(int i=1;i<=n-j;i++)
System.out.print("1");
System.out.print("\n");
}
}
}
}