Advertisement
andkamen

disk

Feb 18th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package com.Ch1_ArraysAndStrings;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class disk {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         int length = Integer.parseInt(scan.nextLine());
  10.         int radius = Integer.parseInt(scan.nextLine());
  11.         int center = length / 2;
  12.  
  13.  
  14.         for (int row = 0; row < length; row++) {
  15.             for (int col = 0; col < length; col++) {
  16.                 boolean isInCircle = (Math.sqrt(Math.pow(row - center, 2) + Math.pow(col - center, 2))) <= radius;
  17.                 if(isInCircle){
  18.                     System.out.printf("*");
  19.                 }else{
  20.                     System.out.printf(".");
  21.                 }
  22.             }
  23.             System.out.println();
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement