C++ Foundation —— (23) C++14 for and while, do...while
»
    for-loop:
    ------------------------------------------------------------------
    for(int i=0;i<100;i++){
        std::cout<<i<<" ";
    }
    std::cout<<std::endl;
    ------------------------------------------------------------------


    for-each-loop:
    ------------------------------------------------------------------
    for(auto &item:vectorVal){
        std::cout<<item<<std::endl;
    }

    for(auto& pair:mapVal){
        std::cout<<pair.first<<" "<<pair.second<<std::endl;
    }
    ------------------------------------------------------------------

    while-loop
    ------------------------------------------------------------------
    while(true){
        std::cout<<"looping"<<std::endl;
        if(needExitLoop){
            break;
        }
    }
    ------------------------------------------------------------------

    do-while-loop
    ------------------------------------------------------------------
    int count=1;
    do{
        std::count<<"count::::"<<count<<endl;
        --count;
    }while(count>0);
    ------------------------------------------------------------------
«
--Alex.Zhang
--www.v-signon.com Learningers Co-Encouraged
Back
Personal Art: www.up-task.com Unit: Individual
中文 Русский 京ICP备19038994号-2
If the content on this website infringes upon your any rights, please contact me at 1307776259@qq.com for removal