C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[18111] Re:Re:Re: begin() - 6이 아니라 end() - 6이죠.
김백일 [cedar] 799 읽음    2002-05-02 18:00
만해 님이 쓰신 글 :
: 안녕하세요 만해 입니다.
:
: 김백일님 답변 감사 드립니다.
:
: 지금
:
: deque<bool> mask(128);
:
: 이렇게 정의 해서 쓰고 있는데요
:
: 알고리즘에 있는 rotate를 사용하고 있습니다.
:
: 그런데 이 rotate가 left rotate 같네요 맞겠죠~
:
: 이 반대 역활을 하는 함수가 필요한데요
:
: 그러니깐 roght rotate가 필요한데
:
: rotate(mask.begin(),mask.begin()+6,mask.end());

rotate(mask.begin(), mask.end() - 6, mask.end());
으로 하면 됩니다.

: mask.begin()+6 <- 여기다 -6값을 넣으니깐 바로 에러가 나고요
:
: 혹 해서
:
: reverse(mask.begin(),mask.end);
: rotate(mask.begin(),mask.begin()+6,mask.end());
:
: 이렇게 해 봤는데
:
: 전혀 아닌값이 나오고요
:
: 기존의 rotate의 반대 역활을 하는 함수를 직접 구현 해야 하나요?
:
: 아니면 기존의 rotate에서 뭔가 조금 바꾸면 되나요?
:
: 좀 알려주세요
:
: 부탁 드릴께요 그럼 이만

'STL Tutorial and Reference Guide, Second Editon'에 있는 예제를 적습니다.
참고하세요.

// Illustrating the generic rotate algorithm
#include <cassert>
#pragma hdrstop
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main()
{
  cout << "Illustrating the generic rotate algorithm." << endl;
  string s("Software Engineering ");
  vector<char> vector1(s.begin(), s.end());

  // Rotate leftly the vector so that "Engineering " comes first:
  rotate(vector1.begin(), vector1.begin() + 9, vector1.end());

  assert(string(vector1.begin(), vector1.end()) ==
          string("Engineering Software "));
  cout << " --- Ok." << endl;

  // Rotate rightly the vector so that "Software " comes first:
  rotate(vector1.begin(), vector1.end() - 9, vector1.end());

  assert(string(vector1.begin(), vector1.end()) ==
          string("Software Engineering "));
  cout << " --- Ok." << endl;

  return 0;
}

+ -

관련 글 리스트
18090 [만해] STL인데요 좀 봐주세요 만해 770 2002/05/02
18091     Re:[만해] STL인데요 좀 봐주세요 김백일 1099 2002/05/02
18101         Re:Re:[만해] STL인데요 좀 봐주세요 만해 839 2002/05/02
18111             Re:Re:Re: begin() - 6이 아니라 end() - 6이죠. 김백일 799 2002/05/02
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.