Skip to content

Commit

Permalink
Add 21It4 Java
Browse files Browse the repository at this point in the history
  • Loading branch information
zukahai committed Aug 17, 2022
1 parent 4b3d237 commit a4e9dd3
Show file tree
Hide file tree
Showing 38 changed files with 356 additions and 0 deletions.
Binary file added 21IT4-CPP/14_02/14_02.docx
Binary file not shown.
12 changes: 12 additions & 0 deletions 21IT4-CPP/14_02/Ex01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
int n;
cin >> n;
if (n % 2 == 0)
cout << "YES";
else
cout << "NO";
}
12 changes: 12 additions & 0 deletions 21IT4-CPP/14_02/Ex02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
int n;
cin >> n;
if (n >= 100 && n <= 999)
cout << "YES";
else
cout << "NO";
}
Binary file added 21IT4-CPP/14_02/Ex02.exe
Binary file not shown.
14 changes: 14 additions & 0 deletions 21IT4-CPP/14_02/Ex03.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
float n;
cin >> n;
int k = int(n);

if (n == k)
cout << "YES";
else
cout << "NO";
}
Binary file added 21IT4-CPP/14_02/Ex03.exe
Binary file not shown.
15 changes: 15 additions & 0 deletions 21IT4-CPP/14_02/Ex04.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
long long a, b, c;
cin >> a >> b >> c;
long long max = a;
if (max < b)
max = b;
if (max < c)
max = c;

cout << max;
}
Binary file added 21IT4-CPP/14_02/Ex04.exe
Binary file not shown.
11 changes: 11 additions & 0 deletions 21IT4-CPP/14_02/Ex05.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <bits/stdc++.h>
using namespace std;

int main()
{
long long a, b;
cin >> a >> b;
long long sum;
sum = ((a+b)*(b-a+1))/2;
cout << sum;
}
Binary file added 21IT4-CPP/14_02/Ex05.exe
Binary file not shown.
10 changes: 10 additions & 0 deletions 21IT4-CPP/14_02/Ex06.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <bits/stdc++.h>

using namespace std;

int main(){
int n;
cin >> n;
for (int i = 1; i <= 10; i++)
cout << n << " x " << i << " = " << n * i << endl;
}
Binary file added 21IT4-CPP/14_02/Ex06.exe
Binary file not shown.
17 changes: 17 additions & 0 deletions 21IT4-CPP/14_02/Ex07.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <bits/stdc++.h>

using namespace std;

int a[100000];

int main(){
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];

sort(a, a + n);

for (int i = 0; i < n; i++)
cout << a[i] << " ";
}
Binary file added 21IT4-CPP/14_02/Ex07.exe
Binary file not shown.
24 changes: 24 additions & 0 deletions 21IT4-CPP/14_02/Ex08.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <bits/stdc++.h>

using namespace std;

int a[100009];

int main(){
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];

sort(a, a + n);

// for (int i = 0; i < n; i++)
// cout << a[i] << " ";

int count = 1;
for (int i = 1; i < n; i++)
if (a[i] != a[i - 1])
count++;

cout << count;
}
Binary file added 21IT4-CPP/14_02/Ex08.exe
Binary file not shown.
13 changes: 13 additions & 0 deletions 21IT4-CPP/14_02/Ex09.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
string s;
getline(cin, s);
for (int i = 0; i < s.length(); i++) {
if (s[i]>='a' && s[i]<='z')
s[i] -= 32;
}
cout << s;
}
Binary file added 21IT4-CPP/14_02/Ex09.exe
Binary file not shown.
40 changes: 40 additions & 0 deletions 21IT4-CPP/14_02/ThiVong2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <cmath>
using namespace std;

int main() {
int n,k;
cin>>n>>k;

int a[n];

for (int i =0;i<n;i++){
cin >>a[i];
}

for(int i =0;i<n;i++){
for(int j = i+1 ;j<n;j++){
if(a[i] < a[j]){
swap(a[i],a[j]);
}
}
}
int dem =0;
int hang=0;
int t=0;
for(int i =0;i<n;i++){

if(a[i]!=0){
t=t+a[i];
dem++;
hang++;
}

if(hang >= k){
break;
}
}
if(t==0) cout<<"0";
else
cout <<dem;
}
2 changes: 2 additions & 0 deletions 21IT4-CPP/14_02/tempCodeRunnerFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
< n; i++)
// cout << a[i] << " ";
13 changes: 13 additions & 0 deletions 21IT4-CPP/21IT4/Ex01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
long long n;
cin >> n;

if (n >= 10 && n <= 99)
cout << "YES";
else
cout << "NO";
}
Binary file added 21IT4-CPP/21IT4/Ex01.exe
Binary file not shown.
18 changes: 18 additions & 0 deletions 21IT4-CPP/21IT4/Ex02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
long long n;
cin >> n;
// n = 123
int sum = 0;

while (n > 0) {
int d = n % 10;
sum = sum + d;
n = n / 10;
}

cout << sum;
}
Binary file added 21IT4-CPP/21IT4/Ex02.exe
Binary file not shown.
15 changes: 15 additions & 0 deletions 21IT4-CPP/21IT4/Ex03.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <bits/stdc++.h>

using namespace std;

long long sum(long long n) {
return n * (n + 1) / 2;
}

int main() {
long long a, b;
cin >> a >> b;
cout << sum(b) - sum(a - 1);
}

// 1 2 3 ... a-1 a ... b
Binary file added 21IT4-CPP/21IT4/Ex03.exe
Binary file not shown.
10 changes: 10 additions & 0 deletions 21IT4-CPP/21IT4/Ex04.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
long long a;
cin >> a;
long long sum = a * (a + 1) / 2;
cout << sum;
}
Binary file added 21IT4-CPP/21IT4/Ex04.exe
Binary file not shown.
16 changes: 16 additions & 0 deletions 21IT4-CPP/21IT4/Ex05.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bits/stdc++.h>

using namespace std;

int a[100009];

int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];

for (int i = 0; i < n; i++)
if (a[i] % 2 == 0 && i % 2 == 1)
cout << a[i] << endl;
}
Binary file added 21IT4-CPP/21IT4/Ex05.exe
Binary file not shown.
17 changes: 17 additions & 0 deletions 21IT4-CPP/21IT4/SapXepMang.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <bits/stdc++.h>

using namespace std;

int a[100009];

int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];

sort(a, a + n);

for (int i = 0; i < n; i++)
cout << a[i] << " ";
}
Binary file added 21IT4-CPP/21IT4/SapXepMang.exe
Binary file not shown.
49 changes: 49 additions & 0 deletions 21IT4-CPP/21IT4/SapXepMang2Chieu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <bits/stdc++.h>

using namespace std;

int a[1009][1009];
int b[1000009];

int main() {
int m, n;
cin >> m >> n;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}

// chuyen mang 2 chieu ve mang 1 chieu
int index = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
b[index] = a[i][j];
index = index + 1;
}
}

// sap xep mang 1 chieu
sort(b, b + m * n);

// for (int i = 0; i < m * n; i++)
// cout << b[i] << " ";

// Dua mang 1 chieu da sap xep ve mang 1 chieu
index = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
a[i][j] = b[index];
index = index + 1;
}
}

cout << "Mang sau khi da sap xep" << endl;

for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout << a[i][j] << " ";
}
cout << endl;
}
}
Binary file added 21IT4-CPP/21IT4/SapXepMang2Chieu.exe
Binary file not shown.
24 changes: 24 additions & 0 deletions 21IT4-CPP/21IT4/XuongDong.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
string s;
getline(cin, s);

bool check = false;

for (int i = 0; i < s.length(); i++)
if (s[i] == ' ')
check = true;

if (check == false || s.length() > 100)
cout << "N";
else {
for (int i = 0; i < s.length(); i++)
if (s[i] == ' ')
cout << endl;
else
cout << s[i];
}
}
Binary file added 21IT4-CPP/21IT4/XuongDong.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions 21IT4-CPP/21IT4/mang2chieu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <bits/stdc++.h>

using namespace std;

int a[1009][1009];

int main() {
int m, n;
cin >> m >> n;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}

for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout << a[i][j] << " ";
}
cout << endl;
}
}
2 changes: 2 additions & 0 deletions 21IT4-CPP/21IT4/tempCodeRunnerFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
i < m * n; i++)
// cout << b[i] << " ";

0 comments on commit a4e9dd3

Please sign in to comment.