普利茅斯gtx多少钱:画流程图并编程

来源:百度文库 编辑:中科新闻网 时间:2024/05/11 03:13:58
1.出入一个圆的半径,计算该圆的圆面积和周长并输出结果.
2.输入平面直角坐标系中两点的坐标,计算两点之间的距离并输出结果.

我用C语言的.
#include <math.h>
#define PI 3.1415
main()
{
float cy,sq,r,x,y,x1,y1;
printf("Please input the r:);
printf("Please input x,y,x1,y1);
scanf("%f,%f,%f,%f,%f",&r,&x,&y,&x1,&y1);
cy=2*r*r*PI;
sq=r*r*PI;
l=sqrt(abs((x-x1)*(x-x1)+(y-y1)*(y-y1)));
printf("%f,%f,%f",cy,sq,l);
}

用什么呢?

1.import java.util.Scanner;

public class Area
{
public static final double PI = 3.14159;
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please input the radius");
double radius = input.nextDouble();
System.out.println("The girth is " + .5 * PI * radius * radius);
System.out.println("The area is " + PI * radius * radius);
}
}

2. import java.util.Scanner;

public class Length
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please input the coordinates of the first point");
double aX = input.nextDouble();
double aY = input.nextDouble();
System.out.println("Please input the coordinates of the second point");
double bX = input.nextDouble();
double bY = input.nextDouble();

double ab = Math.sqrt((aY - bY) * (aY - bY) + (aX - bX) * ( aX - bX));
System.out.println("The distance is " + ab);
}
}