//damody #include <iostream> int main() { unsigned long long a; long b = 1,d; char e; bool f; using namespace std; do { cout << "請輸入一個正整數:__________\b\b\b\b\b\b\b\b\b\b"; f = 1; b = 1; cin >> a; if (a > 0 and a <= 10000000) { while (a > 1) { b++; if (a % b == 0) { cout << b; d = 0; while (a % b == 0) { d++; a = a / b; } if (d != 1) cout << " ^ " << d; if (a > 1) cout << " * "; } } } else cout << "超出範圍!"; cout << endl; cout << "是否繼續?(y/n)"; cin.get(); e = getchar(); system("cls"); if (e != 'y') f = 0; } while (f == 1); return 0; }
公告版位
星落的瞬間!放棄的後悔是永遠!
目前分類:各種C++(CMD.EXE中) (43)
- Jul 15 Tue 2008 16:15
質因數分解(C++)
- Jul 12 Sat 2008 18:09
Code::Blocks使用小技巧
滑鼠左鍵在任意單字連點兩下即會將單字反白,
若為變數則顯示其型態。
- Jun 19 Thu 2008 10:26
判斷質數(C++)
原始碼:http://down.gogobox.com.tw/t2329175/jw2m2
//從簡單的開始吧!
/*
Name: 質因數判斷
Date: 19/06/08 09:59
*/
#include
int main()
{
using namespace std;