using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("5"); WillReturn.Add("yuki2006"); WillReturn.Add("rng_58"); WillReturn.Add("sugim48"); WillReturn.Add("02/29/2016"); WillReturn.Add("D programming language version 0.99"); } else if (InputPattern == "Input2") { WillReturn.Add("7"); WillReturn.Add("hoge999hoge"); WillReturn.Add("73-23=49"); WillReturn.Add("O(n^2 log n)"); WillReturn.Add("hoge0003871hoge"); WillReturn.Add("00000000000000000000000"); WillReturn.Add("-0"); WillReturn.Add("piyo"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); string[] SArr = InputList.Skip(1).ToArray(); Regex Pattern = new Regex("[0-9]+(?!.*[0-9])"); foreach (string EachStr in SArr) { string Answer = Pattern.Replace(EachStr, pMatch => { string MatchStr = pMatch.Value; int wkInt = int.Parse(MatchStr); string wkStr = (wkInt + 1).ToString(); //桁数が減るのは認めない if (MatchStr.Length > wkStr.Length) { wkStr = wkStr.PadLeft(MatchStr.Length, '0'); } return wkStr; }); Console.WriteLine(Answer); } } }