/ ***** Accept a decimal form in the N / D form of the population ******** // ***** If his decimal form has a cycle, it is necessary to It comes from **** /
/ ******** Solve can be used in the form of division, ************* // ******************* Commercial and the remainder, **************** // ********** to the rest of 0 live cycle festival ******* *********** /
#include
Void work () {while (left [TOP]! = 0) {TOP ; Left [TOP] = (Left [TOP-1] * 10)% D; Dight [TOP] = (Left [TOP-1] * 10 ) / d; if (TOP> 2) for (int i = 0; i <= TOP; i ) // detection cycle {IF (Left [TOP] == Left [I]) {q = top; return; Else Break;}}}
Void init () {left [0] = n% D; Dight [0] = N / D; TOP = 0; q = 0;}
Void Print () {Printf ("% D /% D =", N, D); if (Dight [0]! = 0) Printf ("% D", Dight [0]); if (TOP> 0) {Printf ("."); If (q> 0) {printf ("); for (int i = 1; i <= q; i ) Printf ("% D ", Dight [i]); printf (")");} Else {for (int i = 1; i <= TOP; i ) Printf ("% D", Dight [i]);
}
Void main () {Printf ("Enter N / D: / N"); scanf ("% D% D", & N, & D); init (); Work (); print ();}