我是菜鸟一个,刚才进TOPCODER转转玩拿了一个250分的题目写着玩的
import java.math.*;
class TVSize{
int[]f=new int[2];
public int[] calcSize(int a,int b,int c)
{
double d=b*b+c*c;
double y=a*c/Math.sqrt(d);
int x=(int)(y*b/c);
int w=(int)y;
f[0]=x;
f[1]=w;
return f;
}
}
大致意思就是通过对角线长度和长宽比求长和宽
TOPCODER中编译通过了,可是测试时说An illegalaccess exception occurred. Make sure your method is declared to be public.
请问为什么???不是已经是PUBLIC了吗?
Definition
Class:
TVSize
Method:
calcSize
Parameters:
int, int, int
Returns:
int[]
Method signature:
int[] calcSize(int diagonal, int height, int width)
(be sure your method is public)
import java.math.*;
class TVSize{
int[]f=new int[2];
public int[] calcSize(int a,int b,int c)
{
double d=b*b+c*c;
double y=a*c/Math.sqrt(d);
int x=(int)(y*b/c);
int w=(int)y;
f[0]=x;
f[1]=w;
return f;
}
}
大致意思就是通过对角线长度和长宽比求长和宽
TOPCODER中编译通过了,可是测试时说An illegalaccess exception occurred. Make sure your method is declared to be public.
请问为什么???不是已经是PUBLIC了吗?
Definition
Class:
TVSize
Method:
calcSize
Parameters:
int, int, int
Returns:
int[]
Method signature:
int[] calcSize(int diagonal, int height, int width)
(be sure your method is public)
class TVSize{
int[]f=new int[2];
public int[] calcSize(int a,int b,int c)
{
double d=b*b+c*c;
double y=a*c/Math.sqrt(d);
int x=(int)(y*b/c);
int w=(int)y;
f[0]=x;
f[1]=w;
return f;
}
}
public class Test
{
public static void main(String[] args)
{
int [] b = new int[2];
TVSize a = new TVSize();
b = a.calcSize(5,3,4);
for(int i = 0;i<2;i++)
System.out.print(b[i]+" ");
}
}