C++11 显示“开始和结束”时出错;“未申报”;我在谷歌上找不到任何理由 void lcm2(){ int noe,数字; cout

C++11 显示“开始和结束”时出错;“未申报”;我在谷歌上找不到任何理由 void lcm2(){ int noe,数字; cout,c++11,c++14,codeblocks,gnu,C++11,C++14,Codeblocks,Gnu,编写了#include int-arg[noe]->std::vector-arg(noe); begin(arg)->arg.begin() end(arg)->arg.end() 第一个是因为在C++中没有可变长度数组,第二个不是完全必要的,但是它们确实会让你免于 >包含< /Cord> > C++标准库头。< /P> C++没有。请使用。 void lcm2(){ int noe,number; cout<<"enter the no. of elements whos

编写了
#include

int-arg[noe]
->
std::vector-arg(noe);

begin(arg)
->
arg.begin()

end(arg)
->
arg.end()


第一个是因为在C++中没有可变长度数组,第二个不是完全必要的,但是它们确实会让你免于<代码> >包含< /Cord> > C++标准库头。< /P> C++没有。请使用。

    void lcm2(){
int noe,number;
cout<<"enter the no. of elements whose lcm you want"<<endl;
cin>>noe;
int arg[noe];
long product=1;
for(number=0;number<noe;number++){
   cout<<"enter the "<<number+1<<"element"<<endl;
   cin>>arg[number];
   product*=arg[number];
   }
   int maximumm=arg[0];
   for(number=0;number<noe;number++){
       if(maximumm<arg[number]){
          maximumm=arg[number];
       }
   }
bool result;
result = std::all_of(begin(arg),end(arg),[](int i){return i%2==0;});
   while(maximumm!=product){
        if(result==true){
         cout<<"the lcm of all the numbers entered is = "<<maximumm<<endl;
         break;
         }
         else{
         maximumm++;
    }
    }
    }