Print a regular grid pattern with diamond-like base elements. Use the \ (backslash) and the / (slash) characters to print diamonds and . (dots) to fill the rest of the space.
Input
You are given t - the number of test cases and for each of the test cases three positive integers: r - the number of rows, c - the number of columns in the grid and s - the size of each diamond.
Output
For each of the test cases output the requested pattern (please have a look at the example). Use one line break in between successive patterns.
Example
Input: 3 3 1 2 4 4 1 2 5 2 Output: ./\. /..\ \../ .\/. ./\. /..\ \../ .\/. ./\. /..\ \../ .\/. /\/\/\/\ \/\/\/\/ /\/\/\/\ \/\/\/\/ /\/\/\/\ \/\/\/\/ /\/\/\/\ \/\/\/\/ ./\../\../\../\../\. /..\/..\/..\/..\/..\ \../\../\../\../\../ .\/..\/..\/..\/..\/. ./\../\../\../\../\. /..\/..\/..\/..\/..\ \../\../\../\../\../ .\/..\/..\/..\/..\/.思路:根据size来确定模
1、(row+col)%(2*size) = size - 1输出/
2、abs(row-col)%(2*size)=size输出\
3、否则输出.
注意:在循环中调用echo超时。将字符串拼凑完后, 再输出
<?php
$str_n = fgets(STDIN);
$n = (int)explode(' ', $str_n)[0];
while ($n--)
{
$line = fgets(STDIN);
$data = explode(' ', $line);
$r = intval($data[0]);
$c = intval($data[1]);
$size = intval($data[2]);
$tmp = 2 * $size;
$row = $r * $tmp;
$col = $c * $tmp;
$mod1 = $size - 1;
$mod2 = $size;
$ans = "";
for ($i = 0; $i < $row; $i++)
{
for ($j = 0; $j < $col; $j++)
{
if ($mod1 == ($i + $j) % $tmp)
{
$ans .= '/';
}
else if ($mod2 == abs($i - $j) % $tmp)
{
$ans .= '\\';
}
else
{
$ans .= '.';
}
}
$ans .=PHP_EOL;
}
echo($ans);
}