(数据结构)求循环小数:
对于任意的真分数 N/M ( 0 < N < M ),均可以求出对应的小数。如果采用链表表示各个小数,对于循环节采用循环链表表示,则所有分数均可以表示为如下链表形式。
输入: N M
输出: 转换后的小数(不超过 50 )
要求: 仅编写将分数转换为小数的函数 change( int n, int m, NODE * head ) 。
预设代码
前置代码
/* PRESET CODE BEGIN - NEVER TOUCH CODE BELOW */
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int data;
struct node * next;
} NODE;
void output( NODE * );
void change( int, int, NODE * );
void output( NODE * head )
{
int k=0;
printf("0.");
while ( head->next != NULL && k<50 )
{
printf(