using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int number = Convert.ToInt32(Console.ReadLine());
var result = find3InNumber(number);
Console.WriteLine("Digit '3' indexes:");
Console.WriteLine("[{0}]", string.Join(", ", result));
}
private static int[] find3InNumber(int number){
return findCharInString('3',number.ToString());
}
private static int[] findCharInString(char dig,string str){
var places = new List<int>(4);
for(int i = 0;i < str.Length; i++){
if (dig == str[i])
places.Add(i);
}
return places.ToArray();
}
}
Comments
Leave a comment