输出
Enter a number(0-10): 3
3 x 2 x 1
3!= 6
如何在java中编写代码?
import java.util.Scanner;
public class Assign
{
public static void main(String[]args)
{
Scanner n=new Scanner(System.in);
int num=0;
System.out.print("Enter a number(0-10): ");
num=n.nextInt();
for(y=num;y>1;y--)
{
System.out.print(y);
}
}
}
我只有这个代码。 输出:
Enter a number(0-10): 3
321
答案 0 :(得分:-1)
import java.util.Scanner
public class Assign
{
public static void main(String[]args)
{
Scanner n=new Scanner(System.in);
int num=0;
System.out.print("Enter a number(0-10): ");
num=n.nextInt();
int out = 1;
for(y=num;y>1;y--)
{
System.out.print(y+"*");
if(y==2)
System.out.println(1);
out*=y;
}
System.out.println(num+"!="+out);
}
}