클래스의 경우 숫자 값을 equivalent로 변환해야하는 과제가 있습니다. 위로도 9999.C# 콘솔에 출력
사전 명령으로이 작업을 수행했지만 배열을 설정 한 후에는이를 수행 할 수 없습니다. 우리는 수업의 네 번째 주이므로 나에게 어렵다. 여기
내 배열 인
string[] ToWordsOne = new string[10] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
string[] ToWordsTen = new string[8] { "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"};
string[] ToWordsTeens = new string[9] { "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
이 프로그램은이 잘 인식하는 것 같다,하지만 난 출력에 갈 때 코드가 아무것도 또는 충돌 말하지 않는다 (I가 만드는 변경에 따라.)
int i = 0;
string output = "";
while (i <= input.Length)
{
if (i == (input.Length))
{
output = output + " " + ToWordsOne[i];
}
if (i == (input.Length))
{
if (input == 1)
{
output = ToWordsTeens[i];
}
else
{
output = output + ToWordsTen[i];
}
}
if (i == (input.Length))
{
output = output + ToWordsOne[i] + " hundred" + " ";
}
if (i == (input.Length))
{
output = ToWordsOne[i] + " thousand" + " ";
}
i++;
이것은 사전에서 결과를 출력하는 데 사용한 코드입니다. ".length"메서드를 사용할 수 없다는 것을 알고 있습니다. 그러나 나는 거기에서 어디로 가야할지 모르고있다.
여기에 아주 좋은 예가 있습니다. http://www.blackbeltcoder.com/Articles/strings/converting-numbers-to-words – active92
[C#으로 숫자를 변환하는] 가능한 중복 (http://stackoverflow.com/questions/2729752/converting-numbers- C에서 날카로운 단어로) – JeetDaloneboy
가능한 중복 - [어떻게 정수를 구두로 변환 할 수 있습니까?] (http://stackoverflow.com/questions/554314/how-can-i-convert-an- 정수 - 표현 - 표현). – ram