7.04.2017

배열 이용하여 문자열 역순으로 출력하기

//배열 이용하여 문자열 역순으로 출력하기
#include <iostream>
using namespace std;

int main(){
char str[] = "Have a nice day";
int length;
int i = 0;
for (; str[i] != '\0'; i++);

length = i;
cout << "Number Counter : " << length <<  endl;
for (int j = i ; j >=0 ; j--)
cout << str[j];

system("pause");
return 0;
}

댓글 없음:

댓글 쓰기