第一题
import java.util.Scanner;
public class First
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
System.out.println("请输入一个数字");
int n=in.nextInt();
System.out.println(n+"的阶乘是:"+factorial(n));
}
public static int factorial(int m)
{
if(m==1)
return(1);
else
return(factorial(m-1)*m);
}
}
第二题
import java.util.Scanner;
public class Second
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
System.out.println("请输入圆的半径:");
double R=in.nextDouble();
yuan g=new yuan(R);
System.out.println("圆的周长是:"+g.perimeter());
System.out.println("圆的面积是:"+g.area());
System.out.println("请输入正方形的边长:");
double B=in.nextDouble();
zhengfangxing z=new zhengfangxing(B);
System.out.println("正方形的周长是:"+z.perimeter());
System.out.println("正方形的面积是:"+z.area());
}
}
class yuan extends shape
{
final double PI=3.1415926;
double r,area,perimeter;
public yuan(double R)
{
r=R;
}
public double area()
{
area=PI*Math.pow(r,2.0);
return area;
}
public double perimeter()
{
perimeter=2*PI*r;
return perimeter;
}
}
class zhengfangxing extends shape
{
double l,area,perimeter;
public zhengfangxing(double L)
{
l=L;
}
public double area()
{
area=l*l;
return area;
}
public double perimeter()
{
perimeter=4*l;
return perimeter;
}
}
abstract class shape
{
public abstract double area();
public abstract double perimeter();
}
对返回的json解析,将得到的值用js的innerHTML写入到指定位置;
demo:
xmlHttp.get("password").toString() 得到password的值
document.getElementById('写入层的id').innerHTML='xmlHttp.get("password").toString() ';
class text
{
float w,h;
static float area;
static float perimeter;
public text(float w,float h)
{
this.w=w;
this.h=h;
}
public static void resualt(float w)
{
area=w*w;
perimeter=4*w;
System.out.println("正方形的边长是:"+w);
System.out.println("面积是:"+area);
System.out.println("周长是:"+perimeter);
}
public static void resualt(float w,float h)
{
area=w*w;
perimeter=4*w;
System.out.println("长方形的长是:"+w+"长方形的长是:"+h);
System.out.println("面积是:"+area);
System.out.println("周长是:"+perimeter);
}
public static void main(String argv[])
{
resualt(4);
resualt(3,4);
resualt(4,6);
}
}
阁下是HENU?
public class E
{
public static void main(String args[])
int n=Integer.parseInt(args[0]);
int m=0;
for(int i=1;i<=n;i++)
{
m=m*n;
}
System.out.println(m+"");
}