+ 2
How to reverse string? C++
If I input daphnyzyb and reversed like byzynhpad?
3 Respuestas
+ 13
https://code.sololearn.com/cNJK5FwXFn5I/?ref=app
My direct approach.
+ 3
thank you!!
+ 1
// C
int main() {
char str[]="ha"; // source string
int l=strlen(str)-1;
if (l<1) return 1;
for (int i = 0; i < l; ++i, --l) {
str[i] ^= str[l] ^= str[i] ^=str[l];
}
cout << str << endl;
return 0;
}
//C++
int main()
{
char* str = "hack"; // source string
reverse_copy(str, str + strlen(str), ostream_iterator<char>(cout));
return EXIT_SUCCESS;
}