发布网友 发布时间:2022-04-23 22:59
共4个回答
热心网友 时间:2023-10-12 22:42
public class test2
{
public static void main(String[] args){
String sName[]= new String[]{"c","b","a","d","e"};
//输出上面的三行
for(int i = 2; i >= 0; i--)
{
for(int j = 0; j < i ; j++)
{
System.out.print(" ");
}
for(int n = 0; n < 5 - 2 * i; n++)
{
System.out.print(sName[i]);
}
System.out.println("");
}
//输出下面的两行
for(int i = 1; i < 3; i ++)
{
for(int j = 0; j < i ; j++)
{
System.out.print(" ");
}
for(int n = 0; n < 5 - 2 * i; n++)
{
System.out.print(sName[i+2]);
}
System.out.println("");
}
}
}
热心网友 时间:2023-10-12 22:42
public class test1
{
public test1()
{
}
public static void main(String[] args)
{
char c = 'a';
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2-i; j++)
{
System.out.print(" ");
}
for (int j = 0; j < 2*i + 1; j++)
{
System.out.print(c);
}
c++;
System.out.println();
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < i; j++)
{
System.out.print(" ");
}
for (int j = 0; j < 5-2*i; j++)
{
System.out.print(c);
}
c++;
System.out.println();
}
}
}
热心网友 时间:2023-10-12 22:42
写几条输出语句就完了,例如
System.out.println(" a");
System.out.println(" bbb");
System.out.println("ccccc");
System.out.println(" ddd");
System.out.println(" e");
热心网友 时间:2023-10-12 22:43
package com.frame;
import java.applet.Applet;
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class A extends Applet
{
/**
*
*/
private static final long serialVersionUID = 1L ;
@Override
public void init()
{
super.init();
new MainFrame();
}
@Override
public void start()
{
super.start();
}
public class MainFrame extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
private JFrame frame;
private final int WIDTH;
private final int HEIGHT;
private JLabel label;
private Robot robot;
private Rectangle rect;
private BufferedImage buffeimage;
/**
* 构造方法
*/
public MainFrame()
{
frame = this;
label = new JLabel();
frame.add(label);
WIDTH=Toolkit.getDefaultToolkit().getScreenSize().width;
HEIGHT= Toolkit.getDefaultToolkit().getScreenSize().height;
frame.setUndecorated(true);
frame.getGraphicsConfiguration().getDevice().setFullScreenWindow(frame);
try
{
robot = new Robot();
rect = new Rectangle(0,0,WIDTH,HEIGHT);
buffeimage = robot.createScreenCapture(rect);
label.setIcon(new ImageIcon(buffeimage));
}
catch (AWTException e)
{
e.printStackTrace();
}
frame.setSize(WIDTH,HEIGHT);
frame.setVisible(true);
}
}
}