linux c++ 第三章

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

.最值:

#include<iostream>
#include<climits>

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<iostream>
#include<climits>
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<iostream>

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 << "Done\n"; 
        return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值