문제2 reverse ¶
#include<iostream> using namespace std; void reverse(char a[],int lengh){ char *b = new char[lengh+1]; for(int i=0; i<lengh; i++) b[i] = a[lengh-i-1]; b[lengh] = a[lengh]; for(i=0;i<lengh;i++) a[i] = b[i]; delete [] b; } void main(){ int i=0,lengh=0; char *a = new char[256]; cin >> a; while(a[i++] != '\0') { lengh++; } cout << lengh << endl; reverse(a,lengh); cout << a << endl; delete [] a; }