类型:JAVA
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4218
思路:1.7320508075688.....的平方为3。然后模拟过程打印
!!!z <= 3[精度问题]
/*hdoj 4218 IMBA?*/
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int t, cnt;
t = cin.nextInt();
for(int i = 1; i <= t; i++){
char[][] ans = new char[40][40];
cnt = cin.nextInt();
for(int i1 = 0;i1 <= 2 * cnt; i1++)
for(int j1 = 0; j1 <= 2 * cnt; j1++)
{
ans[i1][j1] = ' ';
double x, y, z;
x = (i1 - cnt) * (i1 - cnt) + (j1 - cnt) * (j1 - cnt);
y = cnt * cnt;
if(x > y)
z = x - y;
else
z = y - x;
if(z <= 3)
ans[i1][j1] = '*';
}
System.out.println("Case " + i + ":");
for(int i1 = 0; i1 <= 2 * cnt; i1++)
{
for(int j1 = 0; j1 <= 2 * cnt; j1++)
System.out.print(ans[i1][j1]);
System.out.println();
}
}
System.exit(0);
}
}