Large number

xiaoxiao2021-03-05  24

#include

#include

#include

Using namespace std;

Struct Node

{

INT I;

Node * Next;

}

Node * createnode ()

{

Node * node = new node;

Node-> i = 0;

Node-> next = NULL;

Return node;

}

Node * Mullink (Node * HEAD, INT i)

{

Node * p = head;

HEAD-> i = 1;

P = head;

INT TEMP = 0;

For (int J = 1; j <= i; j )

{

While (p)

{

P-> i * = j;

P-> i = TEMP;

IF (P-> i> 9)

{

TEMP = P-> I / 10;

IF (! p-> next)

P-> next = cretenode ();

P-> I% = 10;

P = P-> next;

}

Else

{

TEMP = 0;

P = P-> next;

}

}

P = head;

}

Return head;

}

Void DisplayLink (Node * HEAD)

{

FStream outfile;

Stack display;

Outfile.open ("example.txt", ios :: out | os :: ate);

While (Head)

{

Display.push (head-> i);

HEAD = head-> next;

}

While (! display.empty ())

{

Cout << Display.top ();

Outfile << Display.top ();

Display.pop ();

}

Cout << Endl;

}

Void Freelink (Node * HEAD)

{

Node * p = head;

While (p)

{

HEAD = P-> next;

Delete P;

P = head;

}

}

Int main (int Argc, char * argv [])

{

Int n;

COUT << "please input the number" << endl;

CIN >> N;

Node * head = createnode ();

Mullink (Head, N);

DisplayLink (HEAD);

Freelink (HEAD);

System ("pause");

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-35642.html

New Post(0)