Contents

조회 수 17279 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
string class를 이용하여 문자열을 거꾸로 출력하는 프로그램 작성.

확실히 C style로 하는 것보다 편리하다. 
#include<iostream>
#include<string>
using namespace std;

string ReverseString(const string src, int len)
{
      string reverse;

      for(int i=0;i<len;i++)
            reverse+=src.substr(len-i-1,1);

      return reverse;
}

int main()
{
      string origin;
      //cin>>origin;  //space를 문자열의 끝으로 받아들인다. 
      getline(cin,origin); //한줄을 받아들이는 함수 C++ style

      string copy=ReverseString(origin,origin.size());

      cout<<origin<<endl;
      cout<<copy<<endl;

      return 0;
}


?

  1. [c++] 문자열 뒤집기(문자열 거꾸로 출력)

    Date2013.04.23 CategoryDevelop Byhooni Views17279
    Read More
  2. [java] 입출력 스트림 3부 (오브젝트)

    Date2013.04.23 CategoryDevelop Byhooni Views17134
    Read More
  3. [android] 자동차 리모컨 소스코드

    Date2013.04.23 CategoryDevelop Byhooni Views17082
    Read More
  4. [winmobile] 윈도우 모바일 간단한 테스트 코드 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views17081
    Read More
  5. [ios] None IB vs. StoryBoard 샘플 소스

    Date2013.09.06 CategoryDevelop Byhooni Views16920
    Read More
  6. [ios] PHP로 APNS 프로바이더~

    Date2013.06.27 CategoryDevelop Byhooni Views16842
    Read More
  7. [ios] 푸시알림(APNS)에 대한 php 라이브러리 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views16630
    Read More
  8. 프로그래밍 소스 관련 사이트..

    Date2013.04.23 CategoryDevelop Byhooni Views16485
    Read More
  9. [js] 파이어폭스(Firefox;F/F)에서 outerHTML 작동하도록 만든 메소드

    Date2013.04.23 CategoryDevelop Byhooni Views16441
    Read More
  10. 프로그램 문서 관리 (Doxygen)

    Date2013.04.23 CategoryDevelop Byhooni Views16385
    Read More
  11. [android] 안드로이드 어플 모음 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views16340
    Read More
  12. [c++] p.58 연습문제 2번

    Date2003.04.23 CategoryDevelop Byhooni Views16296
    Read More
Board Pagination Prev 1 ... 7 8 9 10 11 12 13 14 15 16 ... 71 Next
/ 71