CPTTRN2

来源:互联网 发布:搜索算法的主要特征 编辑:程序博客网 时间:2024/06/06 04:00


CPTTRN2 - Character Patterns (Act 2)

#basics

Using two characters: . (dot) and * (asterisk) print a frame-like pattern.

Input

You are given t - the number of test cases and for each of the test cases two positive integers: l - the number of lines and c - the number of columns of a frame.

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:33 14 42 5Output:********..**..***************

我的解题如下:
<?php$hi = fopen('php://stdin', 'r');$ho = fopen('php://stdout', 'w');fscanf($hi, '%d', $num);for($i=0;$i<$num;$i++){$line = trim(fgets($hi,100));list($left, $right) = explode(' ', $line);for($j=0;$j<$left; $j++){for($k=0;$k<$right; $k++){if($j==0||$j==$left-1||$k==0||$k==$right-1)fwrite($ho,  "*");elsefwrite($ho,  ".");}fwrite($ho,  "\n");}fwrite($ho,  "\n");}fclose($ho);fclose($hi);


原创粉丝点击