// 分数化小数.cpp : Defines the entry point for the console application.
//
/*涉及小数点后保留多位——用浮点数直接输出显得很无力*/
//所以输出一个最终的值得变量是难以实现的
//想到的方法就是分位(拆开位)逐一输出
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int a, b, c, q, yu;
scanf("%d %d %d", &a, &b, &c);
q = a / b;
printf("%d.", q);
yu = a%b;
while (c)
{
yu *= 10;
q = yu / b;
printf("%d", q);
yu = yu%b;
c--;
}
system("pause");
return 0;
}
(ps:注意scanf——双引号中最好只输入占位符(%d,%f什么的)千万别多加逗号什么的~~——查错半天)