Develop
2013.04.23 15:28
[c++] 문자열 뒤집기(문자열 거꾸로 출력)
조회 수 17342 댓글 0
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; }
-
[c++] SetWindowPos함수를 이용한 크기조절 예제
-
[c++] 바탕화면 테두리에 자석처럼 붙는 스냅효과..
-
[c++] 트리컨트롤 스텝 3 예제..
-
[c++] 트리컨트롤 스텝 2 예제..
-
[c++] 트리컨트롤 예제1 ㅋㅋ
-
[c++] 윈도우 프로세스뷰어 분석.. ㅋㅋ
-
[c++] 레지스트리 편집하는 부분..ㅡㅡ;
-
[js] 서서히 나타나는 화면.. ㅋㅋ
-
[php] 이미지 회전시키기(gd)
-
[C++] 18일차 과제물, String 클래스 디자인 【 C++ 문제 】
-
[c++] 문자열 뒤집기(문자열 거꾸로 출력)
-
[php] 현재에서 일정한 날짜 더하기..