Topic:
#include <iostream> #include <vector> #include <string> #include <list> #define N 1000005using namespace Std;bool prime[n]={0};vector<int> PS; Store 1 to n all prime numbers void Fenjie (vector<int> & Suyinzi, int x) {//prime factorization for (int i=0;i<ps.size (); i++) {while (x% ps[i] ==0) {suyinzi.push_back (ps[i]); x/=ps[i];}}} Char str[5][31]={"*-*****-**-*****-**-**-**-**-*", "|*|*|***|**| | *|| **|****|| *|| *|","*******-**-**-**-**-*****-**-*","|*|*|*|****|**|**|| *|**|| *|**| "," *-*****-**-*****-**-*****-**-* "};char print[5][4*1000]={0}; Print buffer void set (int col, char ch) {//Start setting the character to be displayed from Col column if (ch = = ' * ') {for (int i=0;i<5;i++) Print[i][col] = ";p rint[2][ Col] = ' * '; return;} for (int i =0;i<5;i++) for (int j=0;j<3;j++) {char temp=str[i][(ch-' 0 ') * * + j];p rint[i][col+j] = temp = = ' * '? ": temp;} }void set (int col, string str) {///starts with the nth column, sets the string to be displayed set (col, ' * '), col ++;for (int i=0;i<str.size (); i++) {Set (col,str [i]); Col + = 3;}} string convert (int x) {//Convert an integer to a string list<char> li; while (x!=0) {Li.push_front (x%10 + ' 0 '); x/= 10;} String str (Li.begin (), Li.end ()); return str;} int main () {for (int. i=2;i<1000;i++) {if (Prime[i]) {continue;} for (int j=i+i;j<n;j+=i) prime[j] = 1;} for (int i =2;i< n;i++) if (!prime[i]) ps.push_back (i); int x;while (cin >> x) {vector<int> Suyinzi;vector <string> Vstr;fenjie (suyinzi,x); for (int i=0;i<suyinzi.size (); i++) {Vstr.push_back (CONVERT (Suyinzi[i]));} int count = Suyinzi.size (), Col=0;::memset (print, 0,sizeof (print)), for (int i=0;i<vstr.size (); i++) {set (Col,vstr[i] ); col + = Vstr[i].size () *3+1;} for (int i=0;i<5;i++) {for (int j=1;j<col;j++) cout << print[i][j];cout << Endl;}} return 0;}
One of the online pen question programming questions of XX company