+ 1

What is wrong with my No numerals!

I passed all case, without case 3. Can someone help me ? class Program { static void Main(string[] args) { string s = Console.ReadLine(); Console.WriteLine(Kajman.NoNumerals(s)); } } public class Kajman { public static string NoNumerals(string str) { Kajman k = new Kajman(); str= k.Ten(str); return str.Replace("0", "zero").Replace("2", "two").Replace("3", "three").Replace("4", "four").Replace("5", "five").Replace("6", "six") .Replace("7", "seven").Replace("8", "eight").Replace("9", "nine").Replace("1", "one"); } public string Ten(string str) { string x = ""; for (int i = 0; i < str.Length; i++) { if (str[i] == '1') { if (str[++i] == '0') { x= str.Replace("10", "ten"); } }else x=str; } return x; } }

6th Jan 2020, 12:56 PM
Kajman 🇵🇱
2 ответов
+ 2
You don't need string ten(). You just need to add Replace("10", "ten") at the return first. So the method will first find "10" and won't find "1". Just make it first and it will be good
6th Jan 2020, 1:22 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Solved thx ! 😀
6th Jan 2020, 1:53 PM
Kajman 🇵🇱