Tuesday, 26 July 2022

You need to take an integer input and then draw the pattern according to it. Say for example if you enter 5 then, the pattern should be like this in PHP

You need to take an integer input and then draw the pattern according to it. Say for example if you enter 5 then, the pattern should be like this

A A A A A

B B B B B

C C C C C

D D D D D

E E E E E 

Input Format: You will take an integer input n from stdin.

Constraints: 1 < = n < = 26

Output Format: Your output should be the pattern according to the input which you had entered.  


Input

5

Output

A A A A A

B B B B B

C C C C C

D D D D D

E E E E E


Program

<?php
/* Read input from STDIN. Print your output to STDOUT*/
$fp = fopen("php://stdin", "r");
fscanf(STDIN, "%d\n", $number);
$alphas = range('A', 'Z');
$columnLength = 5;
for($i=0;$i<$number;$i++){
$space = "";
for($j=0;$j<$columnLength;$j++){
echo $space.$alphas[$i];
$space = " ";
}
echo "\n";
}
?>

 

No comments:

Post a Comment

Git merge branch to another branch

$ git checkout develop $ git pull $ git checkout test-branch $ git merge develop $ git push