Python
首先想到的是用py去做,字符串获取后用split直接分割,分割后输出就行,没有难度
1 s = input() 2 word = s.split(" ") 3 i = len(word) 4 while(i!=1): 5 print(word[i-1],end = ' ') 6 i -= 1 7 print(word[0])
缺点就是速度慢,占内存,做OJ题都这样吧
C++(C改一改输入输出即可)
定义一个二维数组储存字符串,输出直接逆序输出
1 #include<iostream> 2 3 using namespace std; 4 5 int main(){ 6 char s[80][80]; 7 int i = 1; 8 do { 9 cin >> s[i]; 10 i++; 11 }while(cin.get() != ' '); 12 for(;i>2;i--){ 13 cout << s[i-1]; 14 cout << " "; 15 } 16 cout << s[1]; 17 return 0; 18 }
当然我觉得还可以用调库大法
这个题。。。有(te)点(bie)简单