两个简单的问题高手回答
在控制台输出1-35中随机7个数字,7个数字不能重复,用FOR循环不能是死循环
2用JAVA打印出菱形,在线等。。。。。
QQ414416757
import java.util.Scanner; public class Test3_3 { /** * 叱为n */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.print("Enter the n:"); Scanner scan = new Scanner(System.in); int n = scan.nextInt(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n -i; j++) { System.out.print(" "); } for (int j = 1; j <= 2 * i - 1; j++) { System.out.print("*"); } System.out.println(); } for (int i = n - 1; i > 0 ; i--) { for (int j = 1; j <= n -i; j++) { System.out.print(" "); } for (int j = 1; j <= 2 * i - 1; j++) { System.out.print("*"); } System.out.println(); } } }