-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5469e5
commit 6412b44
Showing
5 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int n; | ||
cout << "Nhap so tien khach hang phai tra: "; | ||
cin >> n; | ||
float ans=n; | ||
if (n>=200 && n<300){ | ||
ans-=n*0.2; | ||
} | ||
else if (n>=300){ | ||
ans-=n*0.3; | ||
} | ||
cout << "So tien khach hang phai tra la: " << ans << "\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
float a,b,c; | ||
cout << "Nhap a: "; | ||
cin >> a; | ||
cout << "Nhap b: "; | ||
cin >> b; | ||
cout << "Nhao c: "; | ||
cin >> c; | ||
if (a==0){ | ||
cout << "Phuong trinh tren khong phai phuong trinh bac 2.\n"; | ||
} | ||
else{ | ||
float delta = b*b-4*a*c; | ||
if (delta<0){ | ||
cout << "Phuong trinh vo nghiem.\n"; | ||
} | ||
else if (delta == 0){ | ||
float ans = -b/(2*a); | ||
cout << "Phuong trinh tren co nghiem kep la " << ans << ".\n"; | ||
} | ||
else{ | ||
float n1 = (-b+sqrt(delta))/(2*a); | ||
float n2 = (-b-sqrt(delta))/(2*a); | ||
cout << "Phuong trinh tren co 2 nghiem phan biet la " << n1 << " va " << n2 << ".\n"; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
float x; | ||
int n; | ||
cout << "Nhap vao mot so thuc x: "; | ||
cin >> x; | ||
cout << "Nhap vao mot so nguyen n: "; | ||
cin >> n; | ||
float s=0; | ||
if (n%2==0){ | ||
s+=2016*x; | ||
for (int i=2;i<=n;i++){ | ||
s+=(pow(x,i)/pow(3,i-1)); | ||
} | ||
} | ||
cout << "S = " << s << "\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
bool nguyento(int n){ | ||
if (n<2) return false; | ||
for (int i=2;i<=sqrt(n);i++){ | ||
if (n%i==0) return false; | ||
} | ||
return true; | ||
} | ||
|
||
int main(){ | ||
int n; | ||
cout << "Nhap n: "; | ||
cin >> n; | ||
int sum=0,count=0; | ||
for (int i=1;i<=n;i++){ | ||
if (nguyento(i)==true){ | ||
sum+=i; | ||
count++; | ||
} | ||
} | ||
cout << "Co " << count << " so nguyen to trong doan tu 1 den " << n << ".\n"; | ||
cout << "Tong cua chung la " << sum << ".\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int n; | ||
cout << "Nhap so kWh dien tieu thu trong thang: "; | ||
cin >> n; | ||
long long ans; | ||
if (n<=100){ | ||
ans=n*750; | ||
} | ||
else if (n>100 && n<=200){ | ||
ans=100*750+(n-100)*1250; | ||
} | ||
else if (n>200 && n<=300){ | ||
ans=100*750+100*1250+(n-200)*1750; | ||
} | ||
else{ | ||
ans=100*750+100*1250+100*1750+(n-300)*3000; | ||
} | ||
cout << "So tien dien ho tren phai tra la " << ans << " VND.\n"; | ||
return 0; | ||
} |