17.03.2011, 22:22
|
#14
|
Unity/C# кодер
Регистрация: 03.10.2005
Адрес: Россия, Рязань
Сообщений: 7,568
Написано 3,006 полезных сообщений (для 5,323 пользователей)
|
Ответ: Задачка на математику и логику.
Сообщение от pax
Я бы написал как-то так:
int[,] m= new int[5,5];
int step = 5;
int current = 0;
for(int x=0; x<5; x++)
{
for(int y=0; y<5; y++)
{
current += step;
m[x,y] = current;
if (current % 20 == 0) Console.WtiteLine("m[{0},{1}]={2}", x,y,current );
}
}
|
тогда мод:
int[,] m= new int[5,5];
int step = 5;
int current = 0;
bool found = false;
for(int x=0; x<5; x++)
{
for(int y=0; y<5; y++)
{
current += step;
m[x,y] = current;
if (!found &¤t % 20 == 0)
{
Console.WtiteLine("m[{0},{1}]={2}", x,y,current );
found = true;
}
}
}
|
(Offline)
|
|