题解 | 找出字符串中第一个只出现一次的字符
using System; public class Program { public static void Main() { string line; while ((line = System.Console.ReadLine ()) != null) { // 注意 while 处理多个 case char[] S = line.ToCharArray(); char OC = ' '; for (int i = 0; i < line.Length; i++) { if (!line.Remove(i, 1).Contains(S[i].ToString())) { OC = S[i]; break; } } if (OC == ' ') { Console.WriteLine(-1); } else { Console.WriteLine(OC); } } } }