C++;用户输入关闭程序调试 我得到了一个C++程序,等待用户输入,如果用户输入“q”,只关闭它,如果输入任何其他内容,它将循环回菜单。

C++;用户输入关闭程序调试 我得到了一个C++程序,等待用户输入,如果用户输入“q”,只关闭它,如果输入任何其他内容,它将循环回菜单。,c++,debugging,loops,while-loop,switch-statement,C++,Debugging,Loops,While Loop,Switch Statement,至少这是它应该做的。程序不会循环返回,而是关闭 int main() { Hierarchy roster; char input=' '; bool done = false; string first, last, full, boss, title; while (done != true){ cout << "Organizational Chart builder, version 0.1" << endl;

至少这是它应该做的。程序不会循环返回,而是关闭

int main()
{   
    Hierarchy roster;
    char input=' ';
    bool done = false;
    string first, last, full, boss, title;
    while (done != true){
    cout << "Organizational Chart builder, version 0.1" << endl;
    cout << "Please choose your next command: /n";
    cout << "    q   to quit the program " << endl;
    cout << "    a   to add a person " << endl;
    cout << "    c   to count the number of people under someone" << endl;
    cout << "    p   to print the hierarchy " << endl;
    cout << "    r   to remove someone from the hierarchy " << endl;

    cin >> input;

    switch(input)
    {
    case 'q':
        done = true;
        break;
    case 'a':

        cout << "Please enter the person't first name:  ";
        cin >> first;
        cout << "Please enter the person's last name:  ";
        cin >> last;
        cout << "Please enter the person's title";
        cin >> title;
        cout << "Please enter " + first + last +"'s boss. Please enter the full name and title.  If there is none, type none:";
        cin >> boss;
        if (boss == "none")
        roster.insert(full);
        else 
        roster.contains(boss);
        roster.insert(full);
        break;

    case'c':

        cout << "Enter the first name of the person you are searching for:   ";
        cin >> first;
        cout << "Enter the last name:  ";
        cin >> last;
        cout << "What is the person's title:";
        cin >> title;
        full = first + " " + last + " " + title;
        roster.contains(full);
        roster.countb(full);
        break;

    case 'p':
        roster.print();
        break;

    case 'r':

        cout << "Please enter the first, last, and title of the person you want removed:  ";
        cin >> full;
        roster.removeNode(full);
        break;

    }
  }
cout << "Program closed.  " << endl;
return 0;
    }
intmain()
{   
等级名册;
字符输入=“”;
bool done=false;
字符串第一、最后、完整、boss、标题;
while(完成!=真){

cout您的返回语句在while循环中。取出它,您应该会没事的


即.
返回0;}
->
}返回0;}

您应该更好地缩进代码,这在这种情况下非常有用。