C++是真的U•ェ•*U

想啥呢Word哥!没有幽默感的骆驼就像纸糊的鹰酱一样(非黑即白)Beyond time and space, your name!

#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    //no need to use, but it's ok
    //std::cout << "Hello World!\n";
    string s1("Hello,world!\n");
    cout << s1;

    //endl
    string word;
    
    while (cin >> (word))
    {
        //to test '\0'
        //please enter 'ctrl+z'
        cout << word << endl;
    }
    //attention the following exp
    cin.clear();
    


    //auto and for :
    string str("some string");
    for (auto c : str)
    {
        cout << c << endl;
    }
    //some func by str
    cout << str.size() << endl;
    cout << str.length() << endl;

    //str's func
    //excuse me, can not running
    string results;
    string::size_type n;
    const string hexdigits = "0123456789ABCDEF";
    //cout << "Please enter digits:";
    while (cin >> n)
    {
        if (n < hexdigits.size())
        {
            results += hexdigits[n];
        }
    }
    //redo
    cin.clear();
    cout << results;

    for (auto& cc : hexdigits)
    {
        cout << cc << endl;
    }
    return 0;
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注


皖ICP备2021003932号
召唤伊斯特瓦尔