吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1615|回复: 8
收起左侧

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

[复制链接]
mdl2999_52pj 发表于 2021-5-16 10:35
# include <iostream>
// c++17
using namespace std;

int main()
{
    //类型转换
    double v1 {10.9};
    double v2 {15.9};

    int t1 {static_cast<int>(v1) + static_cast<int>(v2)};
    int t2 {static_cast<int>(v1+v2)};

    cout << v1 << ", " << v1 << ", " << t1 << ", " << t2 ;
}


001.png

免费评分

参与人数 1吾爱币 +2 热心值 +1 收起 理由
苏紫方璇 + 2 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

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

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

int main()
{
    cout << "The range for type short is from " << std::numeric_limits<short>::min() << " to "
        <<  std::numeric_limits<short>::max() << endl;

    cout << "The range for type int is from " << std::numeric_limits<int>::min() << " to "
        <<  std::numeric_limits<int>::max() << endl;

    cout << "The range for type long is from " << std::numeric_limits<long>::min() << " to "
            <<  std::numeric_limits<long>::max() << endl;

    cout << "The range for type float is from " << std::numeric_limits<float>::min() << " to "
            <<  std::numeric_limits<float>::max() << endl;

    cout << "The range for type float is from " << std::numeric_limits<float>::lowest() << " to "
            <<  std::numeric_limits<float>::max() << endl;

    cout << "The range for type double is from " << std::numeric_limits<double>::min() << " to "
            <<  std::numeric_limits<double>::max() << endl;

    cout << "The range for type double is from " << std::numeric_limits<double>::lowest() << " to "
            <<  std::numeric_limits<double>::max() << endl;

    cout << "The range for type long double is from " << std::numeric_limits<long double>::min() << " to "
            <<  std::numeric_limits<long double>::max() << endl;

    cout << "The range for type long double is from " << std::numeric_limits<long double>::lowest() << " to "
            <<  std::numeric_limits<long double>::max() << endl;

}


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

int main()
{
    //字符变量
    char ch{'A'};
    ++ch;
    cout << "ch is '" << ch << "' which is code " << hex << showbase << static_cast<int>(ch) << endl; 
}


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

int main()
{
    //auto 单值初始化 
    auto m{10}; // int
    auto n{200UL}; // unsigned long int
    auto pi{3.14159}; // double

    cout << m << n << pi << endl;

    auto v1 = {3.14159}; // std::initializer_list<double>
    auto v2 = {3,4,5}; // std::initializer_list<int>

    for (auto x:v1)
        cout << x ;
    cout << endl;
    for (auto x:v2)
        cout << x; 
    cout << endl;
}


004.png
致远英才 发表于 2021-5-16 11:43
加油!好好学习天天向上
alan3258 发表于 2021-5-16 11:59
请问用的什么IDE开发的?
头像被屏蔽
tlf 发表于 2021-5-16 13:13
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| mdl2999_52pj 发表于 2021-5-16 13:59
alan3258 发表于 2021-5-16 11:59
请问用的什么IDE开发的?

red panda dev c++
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

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

GMT+8, 2024-11-26 03:34

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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