Получение параметров для консольного приложения - C#
Формулировка задачи:
есть задание,
Input
s [the number of tests <= 10]
n [the number of cities <= 10000]
NAME [city name]
p [the number of neighbours of city NAME]
nr cost [nr - index of a city connected to NAME (the index of the first city is 1)]
[cost - the transportation cost]
r [the number of paths to find <= 100]
NAME1 NAME2 [NAME1 - source, NAME2 - destination]
[empty line separating the tests]
Output
cost [the minimum transportation cost from city NAME1 to city NAME2 (one per line)]
Example
Input:
1
4
gdansk
2
2 1
3 3
bydgoszcz
3
1 1
3 1
4 4
torun
3
1 3
2 1
4 1
warszawa
2
2 4
3 1
2
gdansk warszawa
bydgoszcz warszawa
Output:
3
2
я так понял, консольное приложение может получать много параметров (string[]), я не знаю как обращаться ко все параметрам, потому что динамический нужен код( количество тестов до 10)
подскажите пожалуйста, как работать с аргументами в таком случае???
if (args.Length == 0)
return;
byte test = byte.Parse(args[0]);
int numOfCities = int.Parse(args[1]);
string nameCity = args[2];
if (test < 10)
{
for (byte i = 0; i < test; i++)
{
while (numOfCities == 0)
{
if (nameCity.Length <= 10)
{
byte neighbours = byte.Parse(args[3]);
for (int j = 0; j < neighbours; j++)
{
}
}
}
Console.WriteLine();
Console.WriteLine("-------------------------------");
}
}Решение задачи: «Получение параметров для консольного приложения»
textual
Листинг программы
static void Main()
{
int testSize = int.Parse(Console.ReadLine());
int cityCount = int.Parse(Console.ReadLine());
// и т.д.
}