/ *** Copyright (c) 2004 * all rights: primefactor.cpp * file ID: See Configuration Management Program * Summary: Multiply the form of a number decomposition massiferitude ** Current version: 1.0 * Author: * Tiandong completion date: December 5, 2004 ** replace version: 1.0 * author: enter the original author (or modified by) name * date of completion: December 5, 2004 * / # include
Using namespace std;
Void Print (Long P, INT I);
INT main (void) {char * s; int 1; long n, x, p;
For (;;) {cout << Endl << "Input the number to be divompound:" << endl; cin >> n; if (n <2) Break; print (n, 0 ); For (p = 2, i = 0; (N% P) == 0; i ) {n / = p;} if (i> 0) {Print (p, i);} if (n == 1) {Continue;} x = (long) sqrt ((float) n); for (p = 3; p <= x; p = 2) {for (i = 0; (N% P) == 0 i ) {n / = p;} if (i> 0) {print (p, i);} x = (long) sqrt ((float) n);} if (n> 1) {print (n, 1);}} system ("pause"); return 0;}
Void Print (Long P, INT i) {if (i == 0) {cout <<> <<< P << "= 1";} else {cout << "*" << p; if (i > 1) {cout << "^" << i;}}}