java求大神。都是特别简单的入门级的两个小编程…拜托拜托…明天就要…在线等!!求写详细一些…我真

2024-11-18 23:28:23
推荐回答(2个)
回答1:

import java.util.*;
public class Test
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
System.out.println("请输入一个整数,然后按回车键!");
int row = input.nextInt();
int col = row;
int start = 0;

for(int i=0;i {
System.out.print("\n");
for(int b=0;b {
if(i==b||b==(row-i-1))
System.out.print("1");
else
System.out.print("0");
}
}
}
}
-------------------------------------分割线
public class Test
{
public static void main(String args[])
{
Book b1 = new Book("111111",5,2006,"teacher");
Book b2 = new Book("222222",5,2008,"teacher");
Book b3 = new Book("333333",5,2009,"teacher");
Book b4 = new Book("444444",5,2007,"teacher");
Book b5 = new Book("555555",5,2025,"teacher");
b1.out();
b2.out();
b3.out();
b4.out();
b5.out();
Book books[] = {b1,b2,b3,b4,b5};
b1.getBiggerYear(books);
}
}
class Book
{
private String chuBanShe;//出版社
private int id;//编号
private int year;//年份
private String writer;//作者
public int getYear() {
return year;
}
Book(String chuBanShe,int id,int year,String writer)
{
this.chuBanShe = chuBanShe;
this.id = id;
this.year = year;
this.writer = writer;
}

void out()
{
System.out.println("出版社:"+chuBanShe+" 编号:"+id+" 年份:"+year+" 作者:"+writer);
}

void getBiggerYear(Book books[])
{
int bigger = 0;
int bigger_two = 0;
for(int a=0;a {
if(books[a].getYear()>bigger)
{
bigger = books[a].getYear();
};
}
for(int a=0;a {

if(books[a].getYear()>bigger_two&&books[a].getYear()!=bigger)
{
bigger_two = books[a].getYear();
};
}
System.out.println("year="+bigger+" year="+bigger_two);
}
}

回答2:

让那些初学者帮你写吧