解题思路:
注意事项:
参考代码:
#include <iostream> using namespace std; bool isPrimeNumber(int n) { if(n<2) return false; for(int i=2; i*i<=n; ++i) if(n%i==0) return false; return true; } void PrimeFactor(int a,int b) { int i=a,j=b; for(i; i<=j; ++i) { if(isPrimeNumber(i)) { cout<<i<<"="<<i<<endl; } else { int t = 2; int t1 = i; cout<<t1<<"="; while(t1>1) { if(t1%t==0) { t1 = t1/t; cout<<t; if(t1!=1) cout<<"*"; } else t++; } cout<<endl; } } } int main() { int a,b; cin>>a>>b; PrimeFactor(a,b); return 0; }
0.0分
0 人评分
C二级辅导-同因查找 (C语言代码)浏览:561 |
假币问题 (C++代码)(向上取整的一种处理方式)浏览:1661 |
C二级辅导-公约公倍 (C语言代码)浏览:2122 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:545 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:612 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:531 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:1000 |
【简单计算】 (C语言代码)浏览:622 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:467 |
C语言训练-数字母 (C语言代码)浏览:601 |