1234
誰かがコンソールに4 桁の数字を入力したとします。1 2 3 4
除算とモジュロ演算子のみを使用して、この数値をどのように分離できますか?
public static void MathProblem()
{
Console.WriteLine("Type a four digit number:");
//Ex input: 1234
string inputNumber = Console.ReadLine();
// I'm guessing you first need to parse the
// string as an int in some way?
// And then assign it to some variable
// Now, for seperating the digits to be: 1 2 3 4,
// you can (and must) use both division (/), and the remainder (%).
// The first one will be simple, just dividing value with 1000, but
// how about the others? (Remember, % also need to be used at least
// once)
Console.Write("{0},{1},{2},{3}", value/1000, ?, ?, ?;
}
任意の 4 桁の入力でこれを可能にするためのガイドラインはありますか?