栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

linux c++ 第三章

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

linux c++ 第三章

1.整型:int,short,long,long long,char,unsigned int unsigned short....2

.最值:

#include
#include

int main(void)
{
        using namespace std;

        int n{1};
        cout << "n = " << n << endl;
        int n_int = INT_MAX;
        short n_short = SHRT_MAX;
        cout << "int is " << sizeof n_int << " bytes." << endl;
        cout << "Maximum value: "
             <<"int: " <<  n_int << endl;
        cout << "short is " << sizeof(short) << endl;
        cout << "Maximum value: "
             << "short: " << n_short << endl;
        return 0;
}

3.越界:

#include
#include
using namespace std;

int main(void)
{

        short sam = SHRT_MAX;
        unsigned sue = sam;
        cout << "sam has " << sam << " dollars and sue has "
             << sue << " dollars" << endl;

        sam =sam +1;
        sue =sue +1;
        cout << "sam has " << sam << " dollars and sue has "
             << sue << " dollars" << endl;

        return 0;
}

4.字符以及转义序列的应用:

#include

using namespace std;

int main(void)
{
        char ch ='M';
        int i = ch;
        cout << "Char " << ch << " equals " << i << " in int." << endl; 
        cout << "Add one to " << ch  << endl;
        ch = ch + 1;
        i = ch;
        cout << "Char " << ch << " equals " << i << " in int." << endl;

        cout << "Display char ch: ";
        cout.put(ch);
        cout.put('!');

        cout << endl << "Donen"; 
        return 0;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/968621.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号