이 텍스트 내가 작성한 파일 : 나는 인접한 중복 문자열을 제거하기 위해 노력하고인접한 중복 문자열을 문자열 배열에서 제거 하시겠습니까?
this is the first line
this is the first line
this is the second line
this is the second line
this is the second line
this is the third line
this is the first line
때문에 출력은 다음과 같습니다
this is the first line
this is the second line
this is the third line
this is the first line
이것은 내가 지금까지 쓴 것입니다 :
:for(int i = 0; i < n; i++)
getline(infile,arr[i]);
for(int i=0; i<n; i++)
{
int j = i+1;
if(arr[i] == arr[j])
{
for(int k = i; k<n; k++)
arr[k] = arr[k+1];
n--;
}
}
이
내가 얻을 출력3210해결 방법? 추신 : 반복적으로 해결해야하므로이 방법을 사용하려고합니다.
'arr'의 유형은 무엇입니까? –
STL을 아십니까? –
이러한 문제를 해결하는 올바른 도구는 디버거입니다. 스택 오버플로를 묻기 전에 코드를 단계별로 실행해야합니다. 자세한 도움말은 [작은 프로그램 디버깅 방법 (Eric Lippert 작성)] (https://ericlippert.com/2014/03/05/how-to-debug-small-programs/)을 참조하십시오. 문제를 재현하는 [최소, 완료 및 확인 가능] (http://stackoverflow.com/help/mcve) 예제와 함께 해당 질문을 \ [편집]해야합니다. 디버거. –