HDU 1321 Reverse Text

题目地址:点击打开链接

思路:STL

AC代码:

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	char a[70];
	int t;
	string s;
	scanf("%d",&t);
	getchar();
	while(t--)
	{
		cin.getline(a,80);
		s = a; 
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}
	return 0;
}

AC代码:

也可以不用输入数字

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	char a[70];
	int t = 0;
	string s;
	while(cin.getline(a,80))
	{
		if(t == 0)
			t = 1;
		else
		{
			s = a; 
			reverse(s.begin(),s.end());
			cout<<s<<endl;
		}
	}
	return 0;
}


你可能感兴趣的:(HDU 1321 Reverse Text)