/*
编写反转字符串的程序。
//*/
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;
template<class T>
void swap_t(T &a, T &b)
{
T tmp;
tmp = a;
a = b;
b = tmp;
}
int main()
{
char a[] = "afjoahgmkabsdkfhashkldjlks";
int sz = sizeof(a);
cout << a << endl;
cout << "size: " << sz << endl;
int begin, end;
begin = 0;
end = sz-2;
for(; begin < end;){
swap_t(a[begin], a[end]);
++begin;
--end;
}
cout << "reversed\n" << a <<endl;
return 0;
}
反转字符串
最新推荐文章于 2022-02-02 20:16:21 发布