質問編集履歴

1

解決したコードを記載

2019/08/31 16:02

投稿

mofu_mofu
mofu_mofu

スコア73

test CHANGED
File without changes
test CHANGED
@@ -79,3 +79,93 @@
79
79
 
80
80
 
81
81
  ```
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ 追記
92
+
93
+
94
+
95
+ ACしたコード
96
+
97
+
98
+
99
+ ```using System.Linq;
100
+
101
+ using System;
102
+
103
+
104
+
105
+ class Program
106
+
107
+ {
108
+
109
+ static void Main(string[] args)
110
+
111
+ {
112
+
113
+ string s = Console.ReadLine();
114
+
115
+ string t = Console.ReadLine();
116
+
117
+ s = String.Concat(s.OrderBy(c => c));
118
+
119
+ t = String.Concat(t.OrderByDescending(c => c));
120
+
121
+
122
+
123
+ Console.WriteLine(isSortedAlphabetically(s,t) ? "Yes" : "No");
124
+
125
+ }
126
+
127
+
128
+
129
+ static bool isSortedAlphabetically(string s, string t)
130
+
131
+ {
132
+
133
+ if (s[0] < t[0])
134
+
135
+ {
136
+
137
+ return true;
138
+
139
+ }
140
+
141
+ else if (s[0] == t[0])
142
+
143
+ {
144
+
145
+ if (s.Length == 1 && t.Length == 2) return true;
146
+
147
+ if (s.Length == 2 && t.Length == 1) return false;
148
+
149
+ if (s.Length == 2 && t.Length == 1) return false;
150
+
151
+ if (s.Length == 1 && t.Length == 1) return false;
152
+
153
+ return isSortedAlphabetically(s.Substring(1), t.Substring(1));
154
+
155
+ }
156
+
157
+ else
158
+
159
+ {
160
+
161
+ return false;
162
+
163
+ }
164
+
165
+ }
166
+
167
+ }
168
+
169
+
170
+
171
+ ```