没有合适的资源?快使用搜索试试~ 我知道了~
试题 算法提高 8-1因式分解 资源限制 时间限制:10.0s 内存限制:256.0MB 问题描述 设计算法,用户输入合数,程序输出若个素数的乘积。例如,输入6,输出2*3。输入20,输出2*2*5。 import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int i=0; while(a!=1) { for(int j=2;j<=
资源详情
资源评论
资源推荐
试题试题 算法提高算法提高 8-1因式分解因式分解
试题试题 算法提高算法提高 8-1因式分解因式分解
资源限制
时间限制:10.0s 内存限制:256.0MB
问题描述
设计算法,用户输入合数,程序输出若个素数的乘积。例如,输入6,输出2*3。输入20,输出2*2*5。
import java.util.Scanner;
public class Main {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int i=0;
while(a!=1) {
for(int j=2;j<=a;j++) {
if(a%j==0) {
if(i!=0) {
System.out.print("*");
}
System.out.print(j);
a=a/j;
break;
}
}
i++;
}
}
}
作者:lipeitong333
weixin_38692184
- 粉丝: 8
- 资源: 933
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0