题解 | #小乐乐改数字#
小乐乐改数字
https://www.nowcoder.com/practice/fcd30aac9c4f4028b23919a0c649824d
using System; public class Program { public static void Main() { string Input = Console.ReadLine(); string OutPut = ""; for (int i = 0; i < Input.Length; i++) { int Num = Convert.ToInt32(Input[i]); //如果是偶数 if (Num % 2 == 0) { OutPut += "0"; } else { OutPut += "1"; } } //处理输出结果 string result = ""; //第一个1是否出现 bool isShow = false; for (int i = 0; i < OutPut.Length; i++) { //找出第一个1出现的位置,如果没有,输出结果则为0 if (OutPut[i] == '0') { if (!isShow) continue; else result += '0'; } else if (OutPut[i] == '1') { result += "1"; isShow = true; } } //全是0的情况 if (result == "") result = "0"; Console.WriteLine(result); } }