本文整理汇总了C#中Scanner.NextDouble方法的典型用法代码示例。如果您正苦于以下问题:C# Scanner.NextDouble方法的具体用法?C# Scanner.NextDouble怎么用?C# Scanner.NextDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.NextDouble方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Scanner input = new Scanner(Console.In);
double height = input.NextDouble();
double[] x = new double[200];
double[] y = new double[200];
int n = input.NextInt() + 1;
for (int i = 0; i < n; i++)
{
x[i] = input.NextDouble();
y[i] = input.NextDouble();
}
int m = input.NextInt() + 1;
n += m;
for (int i = 1; i <= m; i++)
{
x[n - i] = input.NextDouble();
y[n - i] = input.NextDouble();
}
double area = 0;
for (int i = 0; i < n; i++)
{
int j = (i + 1) % n;
area += x[i] * y[j] - x[j] * y[i];
}
double volume = Math.Abs(area) / 2.0 * height;
Console.WriteLine("{0:0.00}", volume);
}
示例2: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
double L = input.NextDouble();
double K = input.NextDouble();
Console.WriteLine("{0:0.00000}", f(N, L, K));
}
示例3: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
double res = input.NextDouble();
double K = input.NextDouble();
double left = 0, right = 200000000;
while (right - left > 1e-9) {
double L = (left + right) / 2;
if (f(N, L, K) > res)
right = L;
else
left = L;
}
Console.WriteLine("{0:0.00000}", (left + right) / 2);
}
示例4: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
double L = input.NextDouble();
K = input.NextDouble();
AA = new Vertex();
AA.x = input.NextDouble();
AA.y = input.NextDouble();
BB = new Vertex();
BB.x = input.NextDouble();
BB.y = input.NextDouble();
root = new Vertex();
root.x = 0;
root.y = 0;
root.heading = Math.PI / 2;
root.parent = null;
snowflake(root, N, L);
double res = 0;
while (A != B) {
res += A.DistanceTo(A.parent);
res += B.DistanceTo(B.parent);
A = A.parent;
B = B.parent;
}
Console.WriteLine("{0:0.00000}", res);
}
示例5: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
Rect[] R = new Rect[N];
double[] xs = new double[2 * N];
for (int i = 0; i < N; i++) {
R[i].x1 = input.NextDouble();
R[i].x2 = R[i].x1 + input.NextDouble();
R[i].y = input.NextDouble();
if (R[i].x2 - R[i].x1 < EPS || R[i].y < EPS)
throw new Exception();
xs[2 * i] = R[i].x1;
xs[2 * i + 1] = R[i].x2;
}
Array.Sort(xs);
double[,] curve = new double[10 * N, 2];
int K = 1;
curve[0, 0] = xs[0];
curve[0, 1] = 0;
for (int i = 0; i < 2 * N - 1; i++) {
double x1 = xs[i];
double x2 = xs[i + 1];
if (x2 - x1 < EPS) continue;
double y = 0;
foreach (Rect r in R) {
if (r.x1 < x1 + EPS && x2 - EPS < r.x2) {
y = Math.Max(y, r.y);
}
}
curve[K, 0] = x1;
curve[K, 1] = y;
curve[K+1, 0] = x2;
curve[K+1, 1] = y;
K += 2;
}
curve[K, 0] = xs[2 * N - 1];
curve[K, 1] = 0;
K++;
for (int pass = 0; pass < 2; pass++) {
int count = 0;
for (int i = 0; i < K; i++) {
if (0 < i && i < K - 1) {
if (Math.Abs(curve[i, 1] - curve[i - 1, 1]) < EPS &&
Math.Abs(curve[i + 1, 1] - curve[i, 1]) < EPS)
continue;
}
if (pass == 0)
count++;
else
Console.WriteLine("{0:0.00000000} {1:0.00000000}", curve[i, 0], curve[i, 1]);
}
if (pass == 0)
Console.WriteLine(count);
}
}