Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.6 kB
2
Indexable
Never
#include <iostream>
using namespace std;

int main()
{
    int number = 0;
    cout << "Enter your choise 1-2:\n";
    cin >> number;
    switch (number)
    {
    case 1:

        int num1, num2, num3, num4, num5;
        cout << "Enter 5 numbers:\n";
        cin >> num1 >> num2 >> num3 >> num4 >> num5;

        if (num5 - num4 == num3 - num2 && num2 - num1)
        {
            cout << "This is arithmetic series\n";
        }

        else
            if (num5 - num4 != num3 - num2 && num2 - num1)
            {
                cout << "Error, This is not arithmetic series\n";
            }

        break;

    case 2:

        int num, digit1, digit2, digit3, digit4, digit5, temp, reversed;
        cout << "Enter number with 5 digits:\n";
        cin >> num;
        if (num < 10000 || num > 99999)
            cout << "Error!\n";
        else
        {
            digit1 = num / 10000;
            temp = num % 10000;
            digit2 = temp / 1000;
            temp = temp % 1000;
            digit3 = temp / 100;
            temp = temp % 100;
            digit4 = temp / 10;
            digit5 = temp % 10;
            reversed = 10000 * digit5 + 1000 * digit4 + 100 * digit3 + 10 * digit2 + digit1;
            if (num == reversed)
            {
                cout << "palindrome";
            }
            else
            {
                cout << "not palindrome";
            }

            break;

    default:
        cout << "An illegal option\n";
        }

        return 0;
    }
}