Untitled

mail@pastecode.io avatar
unknown
java
7 months ago
3.1 kB
2
Indexable
Never
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package Files;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
import java.util.Scanner;

/**
 *
 * @author quant
 */
class MonHoc{
    String ma;
    String ten;
    int tin;

    public MonHoc(String ma, String ten, int tin) {
        this.ma = ma;
        this.ten = ten;
        this.tin = tin;
    }

   
  
    
}

class HocPhan {
    static int num = 1;
    String ma;
    String mon;
    int ngay;
    int kip;
    String gv;
    String phong;

    public HocPhan(String mon, int ngay, int kip, String gv, String phong) {
        this.ma = "HP"+String.format("%03d", num++);
        this.mon = mon;
        this.ngay = ngay;
        this.kip = kip;
        this.gv = gv;
        this.phong = phong;
    }

   
    
    
    
    
}

public class J07075 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(new File("MONHOC.in"));
        int n = Integer.parseInt(sc.nextLine());
        List<MonHoc> mhs = new ArrayList<>();
        while(n-->0){
            String ma = sc.nextLine();
            String ten = sc.nextLine();
            int tin = Integer.parseInt(sc.nextLine());
            MonHoc mh = new MonHoc(ma, ten, tin);
            mhs.add(mh);
        }
        
        sc = new Scanner(new File("LICHGD.in"));
        n = Integer.parseInt(sc.nextLine());
        List<HocPhan> hps = new ArrayList<>();
        while(n-->0){
            String mon = sc.nextLine();
            int ngay = Integer.parseInt(sc.nextLine());
            int kip = Integer.parseInt(sc.nextLine());
            String gv = sc.nextLine();
            String phong = sc.nextLine();
            HocPhan hp = new HocPhan(mon, ngay, kip, gv, phong);
            hps.add(hp);
        }
        String querry = sc.nextLine();
        List<HocPhan> ds = new ArrayList<>();
        for(HocPhan it : hps){
            if(it.gv.trim().equals(querry.trim())){
                ds.add(it);
            }
        }
        
        ds.sort(((HocPhan o1, HocPhan o2) ->{
            if(o1.ngay==o2.ngay){
                if(o1.kip==o2.kip){
                    return o1.gv.compareTo(o2.gv);
                }
                return Integer.compare(o1.kip, o2.kip);
            }
                return Integer.compare(o1.ngay, o2.ngay);
        }));
        
        System.out.println("LICH GIANG DAY GIANG VIEN "+querry+":");
        for(HocPhan it : ds){
            String tenMh ="";
            for(MonHoc mh : mhs){
                if(mh.ma.trim().equals(it.mon.trim())){
                    tenMh = mh.ten;
                    break;
                }
            }
            System.out.println(it.ma+" "+tenMh+" "+it.ngay+" "+it.kip+" "+it.phong);
        }
        
    }
}
Leave a Comment