12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author LH
- */
- public class SquareStar
- {
- public static void main(String[] args) throws Exception
- {
- int m = InteractiveIO.promptForInt("Zahl bitte");
- int n = InteractiveIO.promptForInt("Zahl bitte");
-
-
- int bsize = m/2-n;
- InteractiveIO.write(""+bsize);
- String fullstarline = "";
- String holeLine = "";
- for (int i = 0; i < m; i++)
- {
- fullstarline+="*";
- if(i>=bsize&&(i<m-bsize))
- {
- holeLine+=" ";
- }
- else
- {
- holeLine+="*";
- }
- }
- for (int i = 0; i < m; i++)
- {
- if(i>=bsize&&(i<m-bsize))
- {
- InteractiveIO.write(holeLine);
- }
- else
- {
- InteractiveIO.write(fullstarline);
- }
- }
- }
- }
|