President Barack Obama has not only called on everyone to learn to program, or even to lead by example, to become the first president in American history to write computer code. At the end of 2014, to celebrate the official launch of computer Science Week, Obama wrote a very simple computer code: Draw a square on the screen. Now you draw with him, too!
Input format:
The input gives the square edge length N (3<=n<=21) in a row and a character c that makes up a square edge, spaced by a space.
Output format:
Outputs a square drawn by a given character C. But notice that the row spacing is larger than the column spacing, so to make the result look more like a square, the number of rows we output is actually 50% of the number of columns (rounded rounding).
Input Sample:
Ten A
Sample output:
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1#include <iostream>2#include <cstring>3#include <stdio.h>4 using namespacestd;5 intMain ()6 {7 intn,i,j;8 CharC;9Cin>>n>>C;Ten intm; One if(n%2==0) m=n/2; A Else if(n%2!=0) m=n/2+1; - for(i=1; i<=m;i++) - { the for(j=1; j<=n;j++) - { -cout<<C; - } +cout<<Endl; - } + return 0; A}
PAT Group Programming Ladder-practice set l1-015. Draw a square with Barack Obama