저는 C++ 초보자입니다. 다음 프로그램은 매우 간단합니다. 그러나 "EXIT"가 입력되면 프로그램이 종료되는 이유를 모르지만 이전에 입력 한 이름을 인쇄해야합니다! 사전에break 프로그램을 종료합니다 - C++
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main()
{
set <string> myset;
set <string> :: const_iterator it;
it = myset.begin();
string In;
int i=1;
string exit("EXIT");
cout << "Enter EXIT to print names." << endl;
while(1)
{
cout << "Enter name " << i << ": " ;
cin >> In;
if(In == exit)
break;
myset.insert(In);
In.clear();
i++;
}
while(it != myset.end())
{
cout << *it << " " ;
it ++ ;
}
cout << endl;
}
감사 :
여기에 코드입니다. 당신이 당신의 삽입을 완료 한 후
감사합니다 :) – Nour