"하나 이상의 알파벳 문자가 포함될 수있는 10 자리 전화 번호를 사용할 수있는 프로그램 작성 ... 숫자를 사용하여 해당 번호 표시 ... 등" ABC : 2에서 WXYZ : 9아랍어 숫자 값으로 변환
이 장에서는 루프에 대해 설명하지만 실제로이 문제가 발생하면 실종 상태가됩니다. 나는 코드를 완성했다. 그러나 나는 그것을 생각한다. ...
나의 질문 :이 코드를 줄이는 더 좋은 방법이 있나? 그리고 나는 C# 키워드의 경우 만 사용한다고 생각했는데 다른 방법이 있습니까?
편집 : 당신의 아랍어는 1800WALLTO에 입력 할 수 있으며,이 내가 원하는 않습니다 정확히 내가 작동하지 않는 코드를 요구하고 있지 않다 ALSO 1800925586
당신에게주고 할을 요청합니다. 나는 그것을 더 잘 만드는 방법에 대한 조언이나 조언을 구하고있다. 정말
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int x = 0;
char userInput = ' ';
string inputString = "",
outputString = "";
Console.WriteLine("Enter the digits from the phone number");
do
{
userInput = Console.ReadKey(false).KeyChar;
inputString += userInput;
if (Char.IsLetter(userInput))
userInput = userInput.ToString().ToUpper().ToCharArray()[0];
switch (userInput)
{
case '1':
outputString += '1';
x++;
break;
case '2':
case 'A':
case 'B':
case 'C':
outputString += '2';
x++;
break;
case '3':
case 'D':
case 'E':
case 'F':
outputString += '3';
x++;
break;
case '4':
case 'G':
case 'H':
case 'I':
outputString += '4';
x++;
break;
case '5':
case 'J':
case 'K':
case 'L':
outputString += '5';
x++;
break;
case '6':
case 'M':
case 'N':
case 'O':
outputString += '6';
x++;
break;
case '7':
case 'P':
case 'Q':
case 'R':
case 'S':
outputString += '7';
x++;
break;
case '8':
case 'T':
case 'U':
case 'V':
outputString += '8';
x++;
break;
case '9':
case 'W':
case 'X':
case 'Y':
case 'Z':
outputString += '9';
x++;
break;
case '0':
outputString += '0';
x++;
break;
default:
Console.WriteLine("You entered an incorrect value-Try again");
x--;
break;
}
}
while (x < 10);
Console.WriteLine("\nYou entered {0}", inputString);
Console.WriteLine("Your number is {0}", outputString);
}
}
}
제목이 질문과 일치하지 않는 것 같습니다. 아랍어가이 작업과 관련이 있는지를 명확히 할 수 있습니까? – Thanatos
@ Thanatos, 숫자 0, 1, 2, 3, ... - 오늘날 대부분의 계산 시스템에서 표준 숫자는 [아라비아 숫자]라고도합니다 (http://en.wikipedia.org/wiki/Arabic_numerals). –
예제로 편집 했으므로이 프로그램을 실행하고 다른 숫자로 다른 알파벳을 입력 할 수 있습니다. – Zoro