吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1492|回复: 4
收起左侧

[学习记录] [学习笔记]C++学习第8天

[复制链接]
mdl2999_52pj 发表于 2021-5-20 11:06
# include <iostream>
# include <array>
// c++17
using namespace std;

int main()
{
    int total{};
    int values[]{2,3,5,7,11,13,17,19,23,29};
    for (auto x:values)
        total += x;
    cout << "total = " << total << endl;

    // n!
    cout << "Enter a number named n, let's calculate n! ";
    int n{};
    cin >> n;

    auto result{1LL};

    if (n<2)
        result =1;
    else
        while(n)
            result *= n--;

    cout << "n!= " << result << endl; 
}


001.png

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

 楼主| mdl2999_52pj 发表于 2021-5-20 11:15
# include <iostream>
# include <array>
# include <cctype>
//c++17
using namespace std;

int main()
{

    double temp{};
    double total {};
    int count{};
    char reply{};

    do{
        cout << "Enter a temerature: ";
        cin >> temp;
        total += temp;
        ++count;

        cout << "Do you want to enter another?(y/n): ";
        cin >> reply;

    }while(tolower(reply) == 'y');
    cout << "The average temperature is " << total / count << endl;

}


002.png
醒时对人笑 发表于 2021-5-20 15:05
dysdpf 发表于 2021-5-21 17:35
prochsh 发表于 2021-5-24 11:43
太水了一点,每天学习突出相关语言特性比较好!
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

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

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

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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