Compile Error
/in/foo.c:1:1: error: unknown type name 'import' import java.util.Scanner; ^~~~~~ /in/foo.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token import java.util.Scanner; ^ /in/foo.c:2:1: error: unknown type name 'public' public class jieda2 { ^~~~~~ /in/foo.c:2:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'jieda2' public class jieda2 { ^~~~~~
代码
import java.util.Scanner;
public class jieda2 {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("输入数据:");
int i=input.nextInt();
String msg="";
int fact=1;
if(i<1){
System.out.println("程序有误");
return;
}
System.out.print(i+"!=");
for(int number=1;number<i;number++){
msg+=number+"*";
fact*=i;
}
fact*=i;
msg+=i+"="+fact;
System.out.println(msg);
}
}