当前位置: 首页>>代码示例>>C++>>正文


C++ Converter::vectorToArray方法代码示例

本文整理汇总了C++中Converter::vectorToArray方法的典型用法代码示例。如果您正苦于以下问题:C++ Converter::vectorToArray方法的具体用法?C++ Converter::vectorToArray怎么用?C++ Converter::vectorToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Converter的用法示例。


在下文中一共展示了Converter::vectorToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    Converter *conv = new Converter();
    Tree *x = new Tree;
    stringLinkedList *b;
    b = conv->ConvertArrToLinkedList(a, 10, true);
    vector<string> vec;
    string a[10] = {"Kevin","Elijah","Andrew","Elias","Flynn","Callahan","Staple","Ortiz","Calvin", "Stoehr"};
    bool exit=false;
    string input; // input is a string variable
    while(exit!=true) //Main loop for actually running the "movie store"
    {
        cout<<"======Main Menu======"<<endl;
        cout<<"1. Convert array to linked list"<<endl;
        cout<<"2. Convert linked list to array"<<endl;
        cout<<"3. Convert linked list to vector"<<endl;
        cout<<"4. Convert array to vector"<<endl;
        cout<<"5. Convert vector to array"<<endl;
        cout<<"6. Convert vector to linked list"<<endl;
        cout<<"7. Convert array to hash table"<<endl;
        cout<<"8. Convert hash table to array"<<endl;
        cout<<"9. Convert array to binary search tree"<<endl;
        cout<<"10. Convert binary search tree to array"<<endl;
        cout<<"11. Quit"<<endl;
        cin>>input;
        if(input=="1")
        {
            b = conv->ConvertArrToLinkedList(a, 10, false);
        }
        else if(input=="2")
        {
            conv->ConvertLLToArray(b);
        }
        else if(input=="3")
        {
            conv->ConvertLLToVector(b);
        }
        else if(input=="4")
        {
            vec = conv->arrayToVector(a, 10);
        }
        else if(input=="5")
        {
            conv->vectorToArray(vec);
        }
        else if(input=="6")
        {
            conv->vectorToLinkedList(vec);
        }
        else if(input=="7")
        {
            conv->ArrayToHT(a, 10);
        }
        else if(input=="8")
        {
            conv->HTToArray();
        }
        else if(input=="9")
        {
            cout<<"Array to Binary Search Tree(inorder): "<<endl;
            for(int i = 0; i<10;i++)
                x = conv->ArrToBst(a, 10);
            conv->printNode(x);
        }
        else if(input=="10")
        {
            cout<<"Binary Search Tree to Array: "<<endl;
            conv->BstToArr(x, 10);
        }
        else if(input=="11")
        {
            exit=true;
            cout<<"Goodbye!"<<endl;
        }
        else{ // prevent infinite loop
		cout<<"Please select a menu option."<<endl;
	}
    }
}
开发者ID:soniaszeton,项目名称:Staple_CSCI2270_FinalProject,代码行数:79,代码来源:Elijah.cpp

示例2: main


//.........这里部分代码省略.........
            }
            //Otherwise, the input is not a string and should not be added to the array.
            //Users should be redirected to add another input in the same index.
            else
            {
                cout << "Invalid input. Please enter strings as array values." << endl;
                checkInput = false;
            }
        }
    }

    //Display the array that the user has created.
    cout << "Your starting array is: " << endl;
    for(int j = 0; j < arraySize; j++)
    {
        //Start the array with a curly bracket. Just for ease of reading.
        if(j == 0)
        {
            cout << "{";
        }
        //End the array with a curly bracket. Just for ease of reading.
        if(j == arraySize - 1)
        {
            cout << a[j] << "}" << endl;
            break;
        }
        //Otherwise, display the array values followed by a comma.
        cout << a[j] << ", ";
    }
//_____________*******END BLAINE'S CONTRIBUTION******___________//

	//string a[10] = {"Kevin","Elijah","Andrew","Elias","Flynn","Callahan","Staple","Ortiz","Calvin", "Stoehr"};
    bool exit=false;
    int input = 0;
    while(exit!=true) //Main loop for actually running the "movie store"
    {
        cout<<"======Main Menu======"<<endl;
        cout<<"1. Convert array to linked list"<<endl;
        cout<<"2. Convert linked list to array"<<endl;
        cout<<"3. Convert linked list to vector"<<endl;
        cout<<"4. Convert array to vector"<<endl;
        cout<<"5. Convert vector to array"<<endl;
        cout<<"6. Convert vector to linked list"<<endl;
        cout<<"7. Convert array to hash table"<<endl;
        cout<<"8. Convert hash table to array"<<endl;
        cout<<"9. Convert array to binary search tree"<<endl;
        cout<<"10. Convert binary search tree to array"<<endl;
        cout<<"11. Quit"<<endl;
        cin>>input;
        if(input==1)
        {
            b = conv->ConvertArrToLinkedList(a, 10);
        }
        if(input==2)
        {
            conv->ConvertLLToArray(b);
        }
        if(input==3)
        {
            conv->ConvertLLToVector(b);
        }
        if(input==4)
        {
            vec = conv->arrayToVector(a, 10);
        }
        if(input==5)
        {
            conv->vectorToArray(vec);
        }
        if(input==6)
        {
            conv->vectorToLinkedList(vec);
        }
        if(input==7)
        {
            conv->ArrayToHT(a, 10);
        }
        if(input==8)
        {
            conv->HTToArray();
        }
        if(input==9)
        {
            cout<<"Array to Binary Search Tree(inorder): "<<endl;
            for(int i = 0; i<10;i++)
                x = conv->ArrToBst(a, 10);
            conv->printNode(x);
        }
        if(input==10)
        {
            cout<<"Binary Search Tree to Array: "<<endl;
            conv->BstToArr(x, 10);
        }
        if(input==11)
        {
            exit=true;
            cout<<"Goodbye!"<<endl;
        }
    }
}
开发者ID:bmramsdell,项目名称:Staple_CSCI2270_FinalProject,代码行数:101,代码来源:Elijah.cpp


注:本文中的Converter::vectorToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。