分机号

ps:2015年蓝桥杯国赛Java语言B组第一题


分机号


X老板脾气古怪,他们公司的电话分机号都是3位数,老板规定,所有号码必须是降序排列,且不能有重复的数位。比如:
751,520,321 都满足要求,而,
766,918,201 就不符合要求。

现在请你计算一下,按照这样的规定,一共有多少个可用的3位分机号码?

请直接提交该数字,不要填写任何多余的内容。


package b;

public class Main22 {

	public static void main(String[] args) {
		int count = 0;
		for (int a = 9; a >= 0; a--) {
			for (int b = 9; b >= 0; b--) {
				for (int c = 9; c >= 0; c--) {
					if (a > b && b > c) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}

}

答案:120

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个简单的 Java 代码示例,用于实现企业人事管理系统中的员工和部门功能。请注意,以下示例仅供参考,你可以根据自己的需求进行修改和扩展。 ```java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; class Employee { private int id; private String name; private String gender; private String position; private int age; private double salary; private int departmentId; public Employee(int id, String name, String gender, String position, int age, double salary, int departmentId) { this.id = id; this.name = name; this.gender = gender; this.position = position; this.age = age; this.salary = salary; this.departmentId = departmentId; } public int getId() { return id; } public String getName() { return name; } public String getGender() { return gender; } public String getPosition() { return position; } public int getAge() { return age; } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } public int getDepartmentId() { return departmentId; } } class Department { private int id; private String name; private String description; private int extensionNumber; public Department(int id, String name, String description, int extensionNumber) { this.id = id; this.name = name; this.description = description; this.extensionNumber = extensionNumber; } public int getId() { return id; } public String getName() { return name; } public String getDescription() { return description; } public int getExtensionNumber() { return extensionNumber; } } class HRManagementSystem { private List<Employee> employees; private Map<Integer, Department> departments; public HRManagementSystem() { employees = new ArrayList<>(); departments = new HashMap<>(); } public void createDepartment(int id, String name, String description, int extensionNumber) { Department department = new Department(id, name, description, extensionNumber); departments.put(id, department); System.out.println("部门创建成功!"); } public void addEmployee(Employee employee) { employees.add(employee); System.out.println("员工添加成功!"); } public void displayAllEmployees() { if (employees.isEmpty()) { System.out.println("暂无员工信息!"); } else { System.out.println("所有员工信息:"); for (Employee employee : employees) { System.out.println("工号:" + employee.getId()); System.out.println("姓名:" + employee.getName()); System.out.println("性别:" + employee.getGender()); System.out.println("职位:" + employee.getPosition()); System.out.println("年龄:" + employee.getAge()); System.out.println("月薪:" + employee.getSalary()); int departmentId = employee.getDepartmentId(); Department department = departments.get(departmentId); System.out.println("部门编号:" + department.getId()); System.out.println("部门名称:" + department.getName()); System.out.println("--------------------"); } } } public void displayEmployeeById(int id) { for (Employee employee : employees) { if (employee.getId() == id) { System.out.println("工号:" + employee.getId()); System.out.println("姓名:" + employee.getName()); System.out.println("性别:" + employee.getGender()); System.out.println("职位:" + employee.getPosition()); System.out.println("年龄:" + employee.getAge()); System.out.println("月薪:" + employee.getSalary()); int departmentId = employee.getDepartmentId(); Department department = departments.get(departmentId); System.out.println("部门编号:" + department.getId()); System.out.println("部门名称:" + department.getName()); return; } } System.out.println("找不到指定工号的员工!"); } public void modifyEmployeeSalary(int id, double newSalary) { for (Employee employee : employees) { if (employee.getId() == id) { employee.setSalary(newSalary); System.out.println("员工薪资修改成功!"); return; } } System.out.println("找不到指定工号的员工!"); } public void displayEmployeesByDepartmentId(int departmentId) { if (!departments.containsKey(departmentId)) { System.out.println("找不到指定部门!"); return; } System.out.println("部门编号:" + departmentId); Department department = departments.get(departmentId); System.out.println("部门名称:" + department.getName()); System.out.println("部门介绍:" + department.getDescription()); System.out.println("分机号:" + department.getExtensionNumber()); List<Employee> departmentEmployees = new ArrayList<>(); for (Employee employee : employees) { if (employee.getDepartmentId() == departmentId) { departmentEmployees.add(employee); } } if (departmentEmployees.isEmpty()) { System.out.println("该部门暂无员工!"); } else { System.out.println("部门员工信息:"); for (Employee employee : departmentEmployees) { System.out.println("工号:" + employee.getId()); System.out.println("姓名:" + employee.getName()); System.out.println("性别:" + employee.getGender()); System.out.println("职位:" + employee.getPosition()); System.out.println("年龄:" + employee.getAge()); System.out.println("月薪:" + employee.getSalary()); System.out.println("--------------------"); } } } } public class Main { public static void main(String[] args) { HRManagementSystem system = new HRManagementSystem(); Scanner scanner = new Scanner(System.in); // 创建部门 system.createDepartment(1, "技术部", "负责公司技术开发", 1001); system.createDepartment(2, "市场部", "负责公司市场拓展", 1002); system.createDepartment(3, "人事部", "负责公司人力资源管理", 1003); while (true) { System.out.println("请选择操作:"); System.out.println("1. 添加员工"); System.out.println("2. 查询所有员工信息"); System.out.println("3. 根据员工工号显示员工信息"); System.out.println("4. 修改指定工号员工的薪资"); System.out.println("5. 根据部门号查询部门中的员工"); System.out.println("0. 退出程序"); int choice = scanner.nextInt(); switch (choice) { case 1: System.out.println("请输入员工信息:"); System.out.print("工号:"); int id = scanner.nextInt(); scanner.nextLine(); // 消耗换行符 System.out.print("姓名:"); String name = scanner.nextLine(); System.out.print("性别:"); String gender = scanner.nextLine(); System.out.print("职位:"); String position = scanner.nextLine(); System.out.print("年龄:"); int age = scanner.nextInt(); System.out.print("月薪:"); double salary = scanner.nextDouble(); System.out.print("部门编号:"); int departmentId = scanner.nextInt(); Employee employee = new Employee(id, name, gender, position, age, salary, departmentId); system.addEmployee(employee); break; case 2: system.displayAllEmployees(); break; case 3: System.out.print("请输入要查询的员工工号:"); int displayId = scanner.nextInt(); system.displayEmployeeById(displayId); break; case 4: System.out.print("请输入要修改薪资的员工工号:"); int modifyId = scanner.nextInt(); System.out.print("请输入新的薪资:"); double newSalary = scanner.nextDouble(); system.modifyEmployeeSalary(modifyId, newSalary); break; case 5: System.out.print("请输入要查询的部门编号:"); int departmentIdToDisplay = scanner.nextInt(); system.displayEmployeesByDepartmentId(departmentIdToDisplay); break; case 0: System.out.println("程序已退出。"); return; default: System.out.println("无效的选择!"); break; } } } } ``` 这是一个简单的企业人事管理系统,你可以根据自己的需求进行修改和扩展。希望对你有帮助!如果还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值