Skip to content

Commit

Permalink
Add source code of Lesson 1
Browse files Browse the repository at this point in the history
  • Loading branch information
lamhoangtung committed Jul 14, 2018
1 parent a9ca2da commit 31187f7
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Bai thuc hanh so 1/bai1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>

using namespace std;

int main(){
int a,b;
cout << "Nhap so nguyen a: ";
cin >> a;
cout << "Nhap so nguyen b: ";
cin >> b;
int tong=a+b;
int hieu=a-b;
int tich=a*b;
int thuong=a/b;
int du=a%b;
cout << "Tong cua 2 so nguyen " << a << " va " << b << " la: " << tong << "\n";
cout << "Hieu cua 2 so nguyen " << a << " va " << b << " la: " << hieu << "\n";
cout << "Tich cua 2 so nguyen " << a << " va " << b << " la: " << tich << "\n";
cout << "Thuong cua phep chia 2 so nguyen " << a << " va " << b << " la: " << thuong << "\n";
cout << "Du cua phep chia 2 so nguyen " << a << " va " << b << " la: " << du << "\n";
return 0;
}
15 changes: 15 additions & 0 deletions Bai thuc hanh so 1/bai2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>

using namespace std;

int main(){
int n;
cout << "Nhap mot so nguyen co it hon 5 chu so: ";
cin >> n;
int N = n/1000;
int T = (n%1000)/100;
int C = (n%100)/10;
int D = n%10;
cout << N << " nghin " << T << " tram " << C << " chuc " << D << " don vi.\n";
return 0;
}
13 changes: 13 additions & 0 deletions Bai thuc hanh so 1/bai3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
#include <math.h>

using namespace std;

int main(){
int x;
cout << "Nhap vao so nguyen x: ";
cin >> x;
float f = (x*x+exp(abs(x))+sin(x)*sin(x))/pow(x*x+1,1.0/5);
cout << "f(x) = " << f << "\n";
return 0;
}
20 changes: 20 additions & 0 deletions Bai thuc hanh so 1/bai4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <math.h>

using namespace std;

int main(){
int x1,x2,y1,y2;
cout << "Nhap toa do diem A: ";
cin >> x1 >> y1;
cout << "Nhap toa do diem B: ";
cin >> x2 >> y2;
float D = sqrt(pow(x2-x1,2)+pow(y2-y1,2));
float M = abs(x2-x1)+abs(y2-y1);
float C = 1-((x1*x2+y1*y2)/(sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2)));
cout << "Giua A(" << x1 << "," << y1 << ") va B(" << x2 << "," << y2 << "):\n";
cout << "- Khoang cach Euclidean la: " << D << "\n";
cout << "- Khoang cach Manhattan la: " << M << "\n";
cout << "- Khoang cach Cosin la: " << C << "\n";
return 0;
}
19 changes: 19 additions & 0 deletions Bai thuc hanh so 1/bai5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
#include <math.h>

using namespace std;

int main(){
int x1,x2,x3,y1,y2,y3;
cout << "Nhap toa do diem A: ";
cin >> x1 >> y1;
cout << "Nhap toa do diem B: ";
cin >> x2 >> y2;
cout << "Nhap toa do diem C: ";
cin >> x3 >> y3;
float x = (x1+x2+x3)/3;
float y = (y1+y2+y3)/3;
float inter = sqrt(pow(x1-x,2)+pow(y1-y,2))+sqrt(pow(x2-x,2)+pow(y2-y,2))+sqrt(pow(x3-x,2)+pow(y3-y,2));
cout << "Inter = " << inter << "\n";
return 0;
}

0 comments on commit 31187f7

Please sign in to comment.