ホームページ  >  に質問  >  本文

c/c++ 创建元素个数为500的字符串数组 读入500个长度不超过40的字符串,再输出,大家都是怎么写的?

c/c++ 创建元素个数为500的字符串数组 读了500个长度不超过40的字符串,再输出,大家都是怎么写的?(我知道这个问题很low)

阿神阿神2715日前702

全員に返信(1)返信します

  • 大家讲道理

    大家讲道理2017-04-17 13:12:39

    #include <string>
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        string xs[500];
        for (auto& x : xs)
        {
            cin >> x;
            if (x.size() > 40) /*do something to crash*/;
        }
        for (const auto& x : xs)
        {
            cout << x << endl;
        }
    }

    返事
    0
  • キャンセル返事