Determine the largest of the three numbers

#include <iostream>
using namespace std;
 
int main(a)
{    
    float n1, n2, n3;
 
    cout << "Please enter three numbers:";
    cin >> n1 >> n2 >> n3;
 
    if(n1 >= n2 && n1 >= n3)
    {
        cout << "The maximum number is:" << n1;
    }
 
    if(n2 >= n1 && n2 >= n3)
    {
        cout << "The maximum number is:" << n2;
    }
 
    if(n3 >= n1 && n3 >= n2) {
        cout << "The maximum number is:" << n3;
    }
 
    return 0;
}
Copy the code

To determine leap year

#include <iostream>
using namespace std;
 
int main(a)
{
    int year;
 
    cout << "Enter year:";
    cin >> year;
 
    if (year % 4= =0)
    {
        if (year % 100= =0)
        {
            // // if divisible by 400 is a leap year
            if (year % 400= =0)
                cout << year << It's a leap year.;
            else
                cout << year << "Not a leap year.";
        }
        else
            cout << year << It's a leap year.;
    }
    else
        cout << year << "Not a leap year.";
 
    return 0;
}
Copy the code

Find the greatest common divisor of two numbers

#include <iostream>
using namespace std;
 
int main(a)
{
    int n1, n2;
 
    cout << "Enter two integers:";
    cin >> n1 >> n2;
    
    while(n1 ! = n2) {if(n1 > n2)
            n1 -= n2;
        else
            n2 -= n1;
    }
 
    cout << "HCF = " << n1;
    return 0;
}
Copy the code

Find the least common multiple of two numbers

#include <iostream>
using namespace std;
 
int main(a)
{
    int n1, n2, max;
 
    cout << Enter two numbers:;
    cin >> n1 >> n2;
    
    // Get the maximum number
    max = (n1 > n2) ? n1 : n2;
 
    do
    {
        if (max % n1 == 0 && max % n2 == 0)
        {
            cout << "LCM = " << max;
            break;
        }
        else
            ++max;
    } while (true);
    
    return 0;
}
Copy the code

Take the factorial of a number

#include <iostream>
using namespace std;
 
int main(a)
{
    unsigned int n;
    unsigned long long factorial = 1;
 
    cout << "Enter an integer:";
    cin >> n;
 
    for(int i = 1; i <=n; ++i)
    {
        factorial *= i;
    }
 
    cout << n << The factorial of "is:"<< "=" << factorial;    
    return 0;
}
Copy the code

Implement a simple calculator…

Complete code, please move to the public number: poetic code