#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> #include < math.h> #include <vector> #include <sstream> #include <list> #include <algorithm> #include <time.h> #include <stdarg.h> #include "myLibrary.h"//header file reference more, some and this program independent using namespace Std;const int M = 1000000;int Main (int argc, char *argv[]) {int arr[m];//Every 1 million bits, max 999999arr[0] = 1;int k, m, N, r, num = 1;//k Save a single calculation product, M As a base (input), n is a power (input), r carry, num is an array length cout << "Please enter the contents to be computed in a space-delimited case m n (Calculate the n power of M):" << endl;while (1) {cin >> m >& Gt N;if (!cin.fail () && m > 0 && n > 0) break;cin.clear (); Error bit reset Cin.sync (); Empty buffers Assuming that this function is not added to the loop cout << "input error, please enter again:" << Endl;} Calculate for (int i = 0; i < n; i++) {r = 0;for (int j = 0; j < Num; J + +) {k = arr[j] * m + r;arr[j] = k% m;r = k/m;} while (R > 0) {arr[num++] = r% M;r = r/m;}} Write File *FP = fopen ("D:\\resoult.txt", "W"), fprintf (FP, "%d of%d times" computedPower \ n ", M, N); for (int i = num-1; I >= 0; i--) {if (Arr[i] < 100000 && Arr[i] > 10000 && i! = num-1 ) fprintf (FP, "%s", "0"), else if (Arr[i] < 10000 && Arr[i] > 00 && i! = num-1) fprintf (FP, "%s", " ") Else if (Arr[i] < && arr[i] > + && i! = num-1) fprintf (FP,"%s "," $ "); else if (Arr[i] < && Arr[i] > && i! = num-1) fprintf (FP, "%s", "0000"); else if (Arr[i] < && i! = num -1) fprintf (FP, "%s", "00000"); fprintf (FP, "%d", Arr[i]);} Fclose (FP); system ("pause"); return 0;}
C + + programming calculates 2 of the 1 million square (n-th square of M), long result output file