在杭电acm网站上上传的程序compilation error是什么意思
0_0_19462340_4013\Main.java:3:错误:类elevator是公共的,应在名为elevator.java的文件中声明publicclasselev...
0_0_19462340_4013\Main.java:3: 错误: 类elevator是公共的, 应在名为 elevator.java 的文件中声明
public class elevator
下面是我写的:
import java.util.Scanner;
public class elevator
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int a[][] = new int[1000][1000];
int m = 0;
int c[] = new int[1000];
int n = in.nextInt();
c[1]= n;
while (n != 0)
{
if (n != 0)
{
m = m + 1;
a[m][0] = 0;
for (int i = 1; i <= n; i++)
a[m][i] = in.nextInt();
}
n = in.nextInt();
c[m + 1] = n;
}
int b[] = new int[1000];
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= c[i]; j++)
{
if (a[i][j] - a[i][j - 1] >= 0)
b[i] = b[i] + (a[i][j] - a[i][j - 1]) * 6 + 5;
if (a[i][j] - a[i][j - 1] <= 0)
b[i] = b[i] + (a[i][j - 1] - a[i][j]) * 4 + 5;
}
}
for (int i = 1; i <= 1000; i++)
{
if (b[i] != 0)
System.out.println(b[i]);
else
break;
}
}
} 展开
public class elevator
下面是我写的:
import java.util.Scanner;
public class elevator
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int a[][] = new int[1000][1000];
int m = 0;
int c[] = new int[1000];
int n = in.nextInt();
c[1]= n;
while (n != 0)
{
if (n != 0)
{
m = m + 1;
a[m][0] = 0;
for (int i = 1; i <= n; i++)
a[m][i] = in.nextInt();
}
n = in.nextInt();
c[m + 1] = n;
}
int b[] = new int[1000];
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= c[i]; j++)
{
if (a[i][j] - a[i][j - 1] >= 0)
b[i] = b[i] + (a[i][j] - a[i][j - 1]) * 6 + 5;
if (a[i][j] - a[i][j - 1] <= 0)
b[i] = b[i] + (a[i][j - 1] - a[i][j]) * 4 + 5;
}
}
for (int i = 1; i <= 1000; i++)
{
if (b[i] != 0)
System.out.println(b[i]);
else
break;
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询