1 #include <iostream> 2 #include <algorithm> 3 #include <cmath> 4 #include <cstdio> 5 #include<cstdlib> 6 #include<cstring> 7 #include <vector> 8 #include <queue> 9 #include <map> 10 using namespace std; 11 #define maxn 100100 12 //字典序 13 const int N = 150; 14 char c; 15 char str[105], ans[105]; 16 int t, len; 17 int main() { 18 cin >> t; 19 while (t--) { 20 cin >> str; 21 len = strlen(str); 22 strcpy(ans, str); 23 for (int i = 0; i < len; i++) { 24 c = str[len - 1]; 25 for (int j = len - 1; j >= 1; j--) { 26 str[j] = str[j - 1]; 27 } 28 str[0] = c; 29 if (strcmp(str, ans) < 0) { 30 strcpy(ans, str); 31 } 32 } 33 printf("%s ", ans); 34 } 35 return 0; 36 }