게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
여기서 i랑 j가 뭐하는 건지 궁금합니다 ㅠㅠㅠ
게시물ID : programmer_8534짧은주소 복사하기
작성자 : 오늘은뭘할까
추천 : 0
조회수 : 577회
댓글수 : 7개
등록시간 : 2015/03/11 02:40:36
#include <iostream>
#include <string>
using namespace std;
int main()
{
char input[288][255] = { 0, };
    string temp[288], temp_result[576], result;
int file_n = 0, input_n = 0, rlen = 0 ;
   // 파일 갯수 입력
   cin>>file_n;
   cin.ignore(); // 버퍼에 엔터 들어가있는거 무시
 
   while(file_n>0){
   // 조각들 입력
   while (true)
   {
      std::cin.getline(input[input_n], 256); // 한조각에 최대 256자까지 입력받음
      
      if ( !input[input_n][0] ) // EOF나 \n 만나면 입력 종료
         break;

      rlen += strlen(input[input_n]);
      ++input_n;
   }
   // 원래 파일의 길이는 rlen / ( file_n * input_n / 2 )
   rlen /= input_n / 2;
   
   // A는 무조건 input의 제일 처음 조각.
   int alen = strlen(input[0]); // A의 길이 구함
   int bidx; // 조각 B의 인덱스
   int a=0;
   // A의 길이 + B의 길이 = 원래 파일의 길이
   for (bidx = 1; bidx < input_n; ++bidx)
   {
      if (alen + strlen(input[bidx]) == rlen) 
 {
         temp[a]= input[bidx];
a++;
 }
   }
   for(int b=0; b<a; b++)
   {
temp_result[b] = input[0] + temp[b];
   }
   for(int b=a; b<2*a; b++)
   {
  temp_result[b] = temp[b] + input[0];
   }
  
   for (int i = 0; i < 2*a; i++)
   {
  bool c = true;
  for( int j = 0; j<input_n; j++)
  {
  if (!strcmp(temp_result[i].c_str(), strstr(temp_result[i].c_str(), input[j])))
  {
  
 c = false;
  }
  else if (!strcmp(temp_result[i].c_str(), strstr(temp_result[i].c_str(), input[i])))
  {
  c = true;}
  }
  if(c == true){
result = temp_result[i];
break;
  }
   }

   std::cout << result << std::endl;
   file_n--;
   }
   return 0;
}
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호