ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
/*
* Bai 1
*/
public static HashMap<Integer, Integer> tanSo(int[][] array){
HashMap<Integer,Integer> result = new HashMap<>();
for(int i=0; i<array.length; i++){
for(int j=0; j<array[0].length; j++){
if(result.containsKey(array[i][j])){
int newValue = result.get(array[i][j])+1;
result.put(array[i][j],newValue);
}else{
result.put(array[i][j], 1);
}
}
}
return result;
}
/*
* Bai 2
* 2 loi sai
* iter.next()/2 !=0
* phan else cung phai thuc hien next neu ko iter se ko tiep tuc di tiep
*/
public static boolean kiemTraBoiSo2(Iterator<Integer> iter){
boolean result = false;
while(iter.hasNext()){
int num = iter.next();
if((num % 2) == 0){
result = true;
}
}
return result;
}
package Bai3;
import java.util.HashMap;
public class ThiSinh implements Comparable<ThiSinh>{
private String maTS;
private String hoTen;
private int tongDiem;
private HashMap<DotThi, Integer> diemChiTiet = new HashMap<>();
public ThiSinh(String maTS, String hoTen) {
this.maTS = maTS;
this.hoTen = hoTen;
this.tongDiem = tongDiem();
}
public int tongDiem(){
int result = 0;
if(!diemChiTiet.isEmpty()){
for(Integer diem : diemChiTiet.values()){
result += diem;
}
}
return result;
}
public void themDiem(DotThi dt, int diem){
this.diemChiTiet.put(dt, diem);
}
@Override
public int compareTo(ThiSinh another) {
return tongDiem - another.tongDiem;
}
package Bai3;
public class DotThi {
private String ten;
private String maDT;
public DotThi(String ten, String maDT) {
super();
this.ten = ten;
this.maDT = maDT;
}
package Bai3;
import java.util.TreeSet;
public class MasterCheft {
private int year;
private String national;
private TreeSet<ThiSinh> dsThiSinh;
public MasterCheft(int year, String national) {
this.year = year;
this.national = national;
}
public void addThiSinh(ThiSinh ts){
this.dsThiSinh.add(ts);
}
public void removeThiSinh(ThiSinh ts){
this.dsThiSinh.remove(ts);
}
package Bai4;
import java.util.HashMap;
import java.util.StringTokenizer;
public class CaesarCoding {
private final char[] mangChuCai = new char[]{'A','B','C','D','E','F','G','H','J','K',
'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
private HashMap<Character,Character> taoBangChuCai_MaHoa(int doDich){
HashMap<Character,Character> result = new HashMap<>();
int length = mangChuCai.length;
for(int i=0; i< length; i++){
int viTri = i+doDich;
if(viTri < length){
result.put(mangChuCai[i], mangChuCai[viTri]);
}else{
result.put(mangChuCai[i], mangChuCai[length - viTri]);
}
}
return result;
}
public HashMap<Character,Character> hoaDoi(HashMap<Character,Character> bangCode){
HashMap<Character,Character> result = new HashMap<>();
for(Character key : bangCode.keySet()){
result.put(bangCode.get(key), key);
}
return result;
}
public String process(HashMap<Character,Character> codingTable,String text){
String result ="";
StringTokenizer tokens = new StringTokenizer(text," ?./()*");
while(tokens.hasMoreElements()){
String word = tokens.nextToken();
String codedWord ="";
for(int i=0; i<word.length(); i++){
codedWord += codingTable.get(word.charAt(i));
}
result += codedWord +" ";
}
return result;
}
public String maHoa(int doDich,String text){
HashMap<Character,Character> codingTable = this.taoBangChuCai_MaHoa(doDich);
return this.process(codingTable, text);
}
public String giaiMa(int doDich,String text){
HashMap<Character,Character> codingTable = this.taoBangChuCai_MaHoa(doDich);
return this.process(this.hoaDoi(codingTable), text);
}
Ad

Recommended

Pemrograman visual
Pemrograman visual
Univ. State of Surabaya
?
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015
ihji
?
Ocr code
Ocr code
wi7sonjoseph
?
Deep learning
Deep learning
DrBaljitSinghKhehra
?
Enter The Matrix
Enter The Matrix
Mike Anderson
?
Procedural Content Generation with Clojure
Procedural Content Generation with Clojure
Mike Anderson
?
Chain rule
Chain rule
Lorie Blickhan
?
Introducci¨®n a Elixir
Introducci¨®n a Elixir
Svet Ivantchev
?
Dive into kotlins coroutines
Dive into kotlins coroutines
Freddie Wang
?
C programs
C programs
Azaj Khan
?
Monads from Definition
Monads from Definition
Dierk K?nig
?
Kotlin coroutines
Kotlin coroutines
TSE-JU LIN(Louis)
?
Efnsjdnfsuies
Efnsjdnfsuies
htmrk
?
Python lecture 05
Python lecture 05
Tanwir Zaman
?
±á²¹²õ°ì±ð±ô±ô¤Çѧ¤ÖévÊýÐÍÑÔÓï
±á²¹²õ°ì±ð±ô±ô¤Çѧ¤ÖévÊýÐÍÑÔÓï
ikdysfm
?
Intro
Intro
Cosmin Poieana
?
Chain Rule
Chain Rule
calculusgroup3
?
The chain rule
The chain rule
Shaun Wilson
?
Clojure for Data Science
Clojure for Data Science
Mike Anderson
?
No3
No3
syahronirpl
?
Clojure for Data Science
Clojure for Data Science
henrygarner
?
C++ L04-Array+String
C++ L04-Array+String
Mohammad Shaker
?
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward
?
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88
Mahmoud Samir Fayed
?
The Chain Rule Powerpoint Lesson
The Chain Rule Powerpoint Lesson
Paul Hawks
?
½yÓ‹µÄѧÁ•¤Î»ùµA 4Õ ǰ°ë
½yÓ‹µÄѧÁ•¤Î»ùµA 4Õ ǰ°ë
Ken'ichi Matsui
?
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
Kevin Chun-Hsien Hsu
?
Les nouveaut¨¦s de C# 6
Les nouveaut¨¦s de C# 6
Microsoft
?
The Man In The Back ¨C Exceptional Delaware.pdf
The Man In The Back ¨C Exceptional Delaware.pdf
dennisongomezk
?
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
?

More Related Content

What's hot (20)

Dive into kotlins coroutines
Dive into kotlins coroutines
Freddie Wang
?
C programs
C programs
Azaj Khan
?
Monads from Definition
Monads from Definition
Dierk K?nig
?
Kotlin coroutines
Kotlin coroutines
TSE-JU LIN(Louis)
?
Efnsjdnfsuies
Efnsjdnfsuies
htmrk
?
Python lecture 05
Python lecture 05
Tanwir Zaman
?
±á²¹²õ°ì±ð±ô±ô¤Çѧ¤ÖévÊýÐÍÑÔÓï
±á²¹²õ°ì±ð±ô±ô¤Çѧ¤ÖévÊýÐÍÑÔÓï
ikdysfm
?
Intro
Intro
Cosmin Poieana
?
Chain Rule
Chain Rule
calculusgroup3
?
The chain rule
The chain rule
Shaun Wilson
?
Clojure for Data Science
Clojure for Data Science
Mike Anderson
?
No3
No3
syahronirpl
?
Clojure for Data Science
Clojure for Data Science
henrygarner
?
C++ L04-Array+String
C++ L04-Array+String
Mohammad Shaker
?
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward
?
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88
Mahmoud Samir Fayed
?
The Chain Rule Powerpoint Lesson
The Chain Rule Powerpoint Lesson
Paul Hawks
?
½yÓ‹µÄѧÁ•¤Î»ùµA 4Õ ǰ°ë
½yÓ‹µÄѧÁ•¤Î»ùµA 4Õ ǰ°ë
Ken'ichi Matsui
?
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
Kevin Chun-Hsien Hsu
?
Les nouveaut¨¦s de C# 6
Les nouveaut¨¦s de C# 6
Microsoft
?
Dive into kotlins coroutines
Dive into kotlins coroutines
Freddie Wang
?
Monads from Definition
Monads from Definition
Dierk K?nig
?
Efnsjdnfsuies
Efnsjdnfsuies
htmrk
?
±á²¹²õ°ì±ð±ô±ô¤Çѧ¤ÖévÊýÐÍÑÔÓï
±á²¹²õ°ì±ð±ô±ô¤Çѧ¤ÖévÊýÐÍÑÔÓï
ikdysfm
?
Clojure for Data Science
Clojure for Data Science
Mike Anderson
?
Clojure for Data Science
Clojure for Data Science
henrygarner
?
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward
?
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.3 book - Part 43 of 88
Mahmoud Samir Fayed
?
The Chain Rule Powerpoint Lesson
The Chain Rule Powerpoint Lesson
Paul Hawks
?
½yÓ‹µÄѧÁ•¤Î»ùµA 4Õ ǰ°ë
½yÓ‹µÄѧÁ•¤Î»ùµA 4Õ ǰ°ë
Ken'ichi Matsui
?
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
Kevin Chun-Hsien Hsu
?
Les nouveaut¨¦s de C# 6
Les nouveaut¨¦s de C# 6
Microsoft
?

Recently uploaded (20)

The Man In The Back ¨C Exceptional Delaware.pdf
The Man In The Back ¨C Exceptional Delaware.pdf
dennisongomezk
?
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
?
Health Care Planning and Organization of Health Care at Various Levels ¨C Unit...
Health Care Planning and Organization of Health Care at Various Levels ¨C Unit...
RAKESH SAJJAN
?
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
?
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
?
Overview of Employee in Odoo 18 - Odoo ºÝºÝߣs
Overview of Employee in Odoo 18 - Odoo ºÝºÝߣs
Celine George
?
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
?
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
?
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
?
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
?
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
?
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
?
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
?
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
?
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
?
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
?
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
?
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
?
Assisting Individuals and Families to Promote and Maintain Health ¨C Unit 7 | ...
Assisting Individuals and Families to Promote and Maintain Health ¨C Unit 7 | ...
RAKESH SAJJAN
?
LDMMIA Practitioner Level Orientation Updates
LDMMIA Practitioner Level Orientation Updates
LDM & Mia eStudios
?
The Man In The Back ¨C Exceptional Delaware.pdf
The Man In The Back ¨C Exceptional Delaware.pdf
dennisongomezk
?
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
?
Health Care Planning and Organization of Health Care at Various Levels ¨C Unit...
Health Care Planning and Organization of Health Care at Various Levels ¨C Unit...
RAKESH SAJJAN
?
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
?
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
?
Overview of Employee in Odoo 18 - Odoo ºÝºÝߣs
Overview of Employee in Odoo 18 - Odoo ºÝºÝߣs
Celine George
?
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
?
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
?
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
?
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
?
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
?
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
?
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
?
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
?
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
?
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
?
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
?
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
?
Assisting Individuals and Families to Promote and Maintain Health ¨C Unit 7 | ...
Assisting Individuals and Families to Promote and Maintain Health ¨C Unit 7 | ...
RAKESH SAJJAN
?
LDMMIA Practitioner Level Orientation Updates
LDMMIA Practitioner Level Orientation Updates
LDM & Mia eStudios
?
Ad

Bai giaigk

  • 1. /* * Bai 1 */ public static HashMap<Integer, Integer> tanSo(int[][] array){ HashMap<Integer,Integer> result = new HashMap<>(); for(int i=0; i<array.length; i++){ for(int j=0; j<array[0].length; j++){ if(result.containsKey(array[i][j])){ int newValue = result.get(array[i][j])+1; result.put(array[i][j],newValue); }else{ result.put(array[i][j], 1); } } } return result; } /* * Bai 2 * 2 loi sai * iter.next()/2 !=0 * phan else cung phai thuc hien next neu ko iter se ko tiep tuc di tiep */ public static boolean kiemTraBoiSo2(Iterator<Integer> iter){ boolean result = false; while(iter.hasNext()){ int num = iter.next(); if((num % 2) == 0){ result = true; } } return result; }
  • 2. package Bai3; import java.util.HashMap; public class ThiSinh implements Comparable<ThiSinh>{ private String maTS; private String hoTen; private int tongDiem; private HashMap<DotThi, Integer> diemChiTiet = new HashMap<>(); public ThiSinh(String maTS, String hoTen) { this.maTS = maTS; this.hoTen = hoTen; this.tongDiem = tongDiem(); } public int tongDiem(){ int result = 0; if(!diemChiTiet.isEmpty()){ for(Integer diem : diemChiTiet.values()){ result += diem; } } return result; } public void themDiem(DotThi dt, int diem){ this.diemChiTiet.put(dt, diem); } @Override public int compareTo(ThiSinh another) { return tongDiem - another.tongDiem; } package Bai3; public class DotThi { private String ten; private String maDT; public DotThi(String ten, String maDT) { super(); this.ten = ten; this.maDT = maDT; } package Bai3;
  • 3. import java.util.TreeSet; public class MasterCheft { private int year; private String national; private TreeSet<ThiSinh> dsThiSinh; public MasterCheft(int year, String national) { this.year = year; this.national = national; } public void addThiSinh(ThiSinh ts){ this.dsThiSinh.add(ts); } public void removeThiSinh(ThiSinh ts){ this.dsThiSinh.remove(ts); } package Bai4; import java.util.HashMap; import java.util.StringTokenizer; public class CaesarCoding { private final char[] mangChuCai = new char[]{'A','B','C','D','E','F','G','H','J','K', 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; private HashMap<Character,Character> taoBangChuCai_MaHoa(int doDich){ HashMap<Character,Character> result = new HashMap<>(); int length = mangChuCai.length; for(int i=0; i< length; i++){ int viTri = i+doDich; if(viTri < length){ result.put(mangChuCai[i], mangChuCai[viTri]); }else{ result.put(mangChuCai[i], mangChuCai[length - viTri]); } } return result; } public HashMap<Character,Character> hoaDoi(HashMap<Character,Character> bangCode){ HashMap<Character,Character> result = new HashMap<>(); for(Character key : bangCode.keySet()){ result.put(bangCode.get(key), key); } return result; }
  • 4. public String process(HashMap<Character,Character> codingTable,String text){ String result =""; StringTokenizer tokens = new StringTokenizer(text," ?./()*"); while(tokens.hasMoreElements()){ String word = tokens.nextToken(); String codedWord =""; for(int i=0; i<word.length(); i++){ codedWord += codingTable.get(word.charAt(i)); } result += codedWord +" "; } return result; } public String maHoa(int doDich,String text){ HashMap<Character,Character> codingTable = this.taoBangChuCai_MaHoa(doDich); return this.process(codingTable, text); } public String giaiMa(int doDich,String text){ HashMap<Character,Character> codingTable = this.taoBangChuCai_MaHoa(doDich); return this.process(this.hoaDoi(codingTable), text); }