吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1271|回复: 3
收起左侧

[学习记录] [学习笔记]C++17学习第6天

  [复制链接]
mdl2999_52pj 发表于 2021-5-18 09:58
本帖最后由 mdl2999_52pj 于 2021-5-18 10:00 编辑
# include <iostream>
// c++17
using namespace std;

int main()
{
        int age;
        cout << "Please enter your age in years: ";
        cin >> age;
        int income;
        cout << "Please enter your income in dollars: ";
        cin >> income;
        int balance;
        cout << "Please enter your current balance in dollars: ";
        cin >> balance;
        if (age >= 21 && (income > 2'5000 || balance > 10'0000))
        {
                int loan{};
                if (2*income < balance/2)
                        loan = 2*income;
                else
                        loan = balance/2;
                cout << "\nYou can borrow up to $" << loan << endl;
        }
        else
        {
                cout << "\nUnfortunately, you don't qualify for a loan.\n";
        }
}


001.png

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| mdl2999_52pj 发表于 2021-5-18 10:12
# include <iostream>
// c++17
using namespace std;

int main()
{
    int brown,white;
    cout << "How many brown mice do you have? ";
    cin >> brown;
    cout << "How many white mice do you have? ";
    cin >> white;
    int mice{brown+white};
    cout << "You have " << mice << (mice>1?" mouse ": " mice ") << "in total.\n";
}



002.png
 楼主| mdl2999_52pj 发表于 2021-5-18 10:20
# include <iostream>
// c++17
using namespace std;

int main()
{
    int choice{};
    cout << "Your electronic recipe book is at service.\n";
    cout << "You can choose from the following deliciouse dishes:\n";
    cout << "1 Boiled eggs\n"
        <<  "2 Fired eggs\n"
        <<  "3 Scrambled eggs\n"
        <<  "4 Coddled eggs\n\n"
        <<  "Enter your selection number: ";

    cin >> choice;
    switch(choice)
    {
        case 1:
            cout << "Boil some eggs.\n";
            break;
        case 2:
            cout << "Fry some eggs.\n";
            break;
        case 3:
            cout << "Scramble some eggs.\n";
            break;

        case 4:
            cout << "Coddle some eggs.\n";
            break;
        default:
            cout << "You entered a wrong number.";
            break;

    }
}


003.png
 楼主| mdl2999_52pj 发表于 2021-5-18 10:29
# include <iostream>
# include <cctype>
// c++17
using namespace std;

int main()
{
    char letter{};
    cout << "Enter a letter: ";
    cin >> letter;

    if (isalpha(letter))
    {
        switch(letter)
        {
            case 'A': case 'a':
            case 'E': case 'e':
            case 'I': case 'i':
            case 'O': case 'o':
            case 'U': case 'u':
                cout << "You entered a vowel.\n";
                break;
            default:
                cout << "you entered a consonant.\n";
                break;

        }
    }
    else
    {
        cout << "You didn't enter a letter.\n";
    }
}


004.png
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-26 04:46

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表