我一直认为变长数组在C++中是不允许的(请参阅:Why aren't variable-length arrays part of the C++ standard?)。但是为什么这段代码编译和工作? #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[n]
我尝试codefights.com,发现某人的答案,其中涉及给予所有最长字符串矢量做到这一点的一个问题: std::vector<std::string> r, allLongestStrings(std::vector<std::string> a) {
int b=0;
for (s:a) if (s.size()>b) b=s.size();
for (s:a)