java考试程序题共享.docxVIP

  • 1
  • 0
  • 约1.05万字
  • 约 6页
  • 2021-01-15 发布于广东
  • 举报
资料 PAGE 页码页码/NUMPAGES 总页数总页数 九九乘法表 public class Test{ public static void main(String args[]){ for(int i=1;i 10;i++){ for(int j=1;j 10;j++) System.out.print(j+ * +i+ = +j*i+ \t ); System.out.println(); } } } 杨辉三角 public class Test{ public static void main(String[] args){ int[][] a=new int[10][10]; for(int i=0;i10;i++) for(int j=0;j10;j++) { if (ji) { a[i][j]=1; if(j==0){ a[i][j]=1; }else{ a[i][j]=a[i-1][j-1]+a[i-1][j]; } }else{ a[i][j]=1; } } for(int i=0;i10;i++) { for(int k=1;k=10-i;k++) System.out.printf( ); for(int j=0;j=i;j++){ System.out.printf(%3d ,a[i][j]); } System.out.printf(\n); } } } 输出斐波那契数列的前20个数 public class Test{ public static void main(String[] args){ int i,a=1,b=1,c; for(i=0;i20;i++) { if(i2) { System.out.print(1+\t); } else { c=a+b; System.out.print(c+\t); a=b; b=c; } } } } 定义一个名为 Card 的扑克牌类 public class Card { private String face; private String suit; public Card(String f,String s){ face=f; suit=s; } protected String getFace() { return face; } protected String getSuit() { return suit; } public String toString(){ return face+ +suit; } } 设计一个表示用户的User类 public class User { public static void main(String[] args) { // User user = new User(littleQ,passwQ); // System.out.println(user); Integer a[] = new Integer[] { 0, 1, 2, 3, 4, 5 }; Integer b[] = new Integer[4]; System.arraycopy(a, 1, b, 0, b.length); for (int i = 0; i a.length; i++) System.out.print(a[i]+ ); System.out.println(); for (int i = 0; i b.length; i++) System.out.print(b[i]+ ); } private String name; private String password; private static int sumOfUsers = 0; public User() { this(null, null); } public User(String name) { this(name, null); } public User(String name, String password) { this.name = name;

文档评论(0)

1亿VIP精品文档

相关文档