题意:
给出一串数字,要你输出它的回文数,就这么简单.
分析:
可以用数组去做,也可以用reversed()函数(这个更简单).
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>z
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 const int maxn = ;
int a[maxn]; int main()
{
string s;
while(cin>>s)
{
memset(a, , sizeof(a));
int i;
int len = s.size();
int c = ;
for(i = ; i < len; i++ )
a[c++] = s[i] - '';
int b = ;
for(i = *c-; i >= c; i-- )
a[i] = a[b++];
for(i = ; i < *c; i++ )
printf("%d", a[i]);
printf("\n");
} return ;
}
#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>z
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 int main()
{
string s;
cin >> s;
cout << s;
reverse(s.begin(), s.end()); //将字符串s中的顺序颠倒
cout << s << endl;
}