>  Q&A  >  본문

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

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

阿神阿神2715일 전703

모든 응답(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
  • 취소회신하다