[java]代码库
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String name = scan.next();
String sex = scan.next();
int age = scan.nextInt();
Person p = new Person(name,sex,age);
String name2 = scan.next();
String sex2 = scan.next();
int age2 = scan.nextInt();
Person p2 = new Person(name2,sex2,age2);
String name3 = scan.next();
String sex3 = scan.next();
int age3 = scan.nextInt();
Person p3 = new Person(name3,sex3,age3);
System.out.print(p3.getAvgAge()/3);
scan.close();
}
}
class Person
{
private String name;
private String sex;
private int age;
private static int avgAge = 0;
public Person(String n, String s, int a)
{
name = n;
sex = s;
age = a;
avgAge += age;
}
public int getAvgAge()
{
return avgAge;
}
public void setName(String n)
{
name = n;
}
public void setSex(String s)
{
sex = s;
}
public void setAge(int a)
{
age = a;
}
public String getName() { return name;}
public String getSex() { return sex;}
public int getAge() { return age;}
public void print()
{
System.out.print("name:"+name+"; ");
System.out.print("sex:"+sex+"; ");
System.out.print("age:"+age);
}
}