Bài đăng

Một số dạng bài tập về Hàm có giá trị/ không có giá trị, chương trình con C++

//Tinh chu vi, dien tich hinh tron
//Publisher: Tran Vo Tien Do
//Github: https://github.com/tranvotiendo
//Tính chu vi, diện tích hình tròn
//Publisher: Tran Vo Tien Do
//Github: https://github.com/tranvotiendo
//Date: 14-May-2023
#include <bits/stdc++.h>
using namespace std;
double c,s,r;
double ChuVi (double r) {
    double cv = 2*3.14*r;
    return cv;
}
double DienTich (double r) {
    double dt = 3.14 * r*r;
    return dt;
}
int main (){
    cout<<"Nhap vao gia tri cua ban kinh, r= ";
    cin>>r;
    c=ChuVi(r);
    s=DienTich(r);
    cout<<"Chu vi la: "<<c<<endl;
    cout<<"Dien tich la: "<<s;
    return 0;
}
//Tim so nho nhat trong 3 so - Sử dụng hàm
//Publisher: Tran Vo Tien Do
//Github: https://github.com/tranvotiendo
#include <bits/stdc++.h>
using namespace std;
float minn (float a, float b) {
    if (a<b) return a;
    return b;
}
int main (){
    cout<<"Nhap vao gia tri cua 3 so a,b,c= ";
    float a, b, c, m;
    cin>>a>>b>>c;
    m=minn(minn(a,b),c);
    cout<<"So nho nhat la: "<<m;
    return 0;
}
  
//Tim so lon nhat trong 3 so
//Publisher: Tran Vo Tien Do
//Github: https://github.com/tranvotiendo
#include <bits/stdc++.h>
using namespace std;
float maxx (float a, float b) {
    if (a>b) return a;
    return b;
}
int main (){
    cout<<"Nhap vao gia tri cua 3 so a,b,c= ";
    float a, b, c, m;
    cin>>a>>b>>c;
    m=maxx(maxx(a,b),c);
    cout<<"So lon nhat la: "<<m;
    return 0;
}
  
//Kiểm tra tính chẵn lẻ của số nguyên N với N nhập từ bàn phím. 
//Trong chương trình có sử dụng chương trình con kiểm tra tính chẳn lẻ kiemtra(n)
//Publisher: Tran Vo Tien Do
//Github: https://github.com/tranvotiendo
#include <bits/stdc++.h>
using namespace std;
void kiemtra(int n) {
    if (n%2==0) cout<<n<<" la so chan";
    else cout<<n<<" la so le";
}
int main (){
    cout<<"Nhap vao gia tri cua n= ";
    int n;
    cin>>n;
    kiemtra(n);
    return 0;
}
--------------------------------------------------------------------------------------------


Getting Info...

Đăng nhận xét

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.