输入整数a,b,c
输出a/b,并且保留小数点后c位
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int main()
{
int str[2000];
int a,b,c;
int i=0;
scanf("%d%d%d",&a,&b,&c);
int temp1;
int temp2=a/b; //整数部分
//处理小数部分
temp1=a%b;
while(i<c){
temp1=temp1*10;
if(temp1<b){
str[i++]=0;
}
else{
str[i++]=temp1/b;
temp1=temp1%b;
}
}
printf("%d.",temp2);
for(int j=0;j<c;j++)
printf("%d",str[j]);
return 0;
}