這是簡易版的質因數分解,使用的想法類似於短除法,程式碼不長,給大家做做參考吧~ 看看你能找到多大的質數 #include<iostream>using namespace std;int main(){ int in; //儲存輸入 while(true) { cout<<"Number:"; cin>>in; for(unsigned int x=2;x<=in;x++) { while(in%x==0) { cout<<x<<"*"; in/=x; } } cout<<"\b \n"; } system("pause"); return 0; }