本文主要是介绍ACM/steps Text Reverse,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
代码不是本人的 但很值得参考 !写的很清晰,不用加注释了吧!!!
#include <stdio.h>
#include <string.h>
char str[1000];
int main()
{
int n;
scanf("%d",&n);
gets(str);
while(n--)
{
gets(str);
int m = strlen(str);
int k = 0;
for(int i = 0; i <= m; i++)
{
if((str[i]==' ')||(str[i]=='\0'))
{
for(int j = i-1; j >= k; j--)
{
cout<<str[j];
}
if(str[i]==' ')
cout<<" ";
else if(str=='\0')
cout<<endl;
k = i + 1;
}
}
cout<<endl;
}
return 0;
}
这篇关于ACM/steps Text Reverse的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!