c 为什么解答错误?

Camelia 发表于 4个月前 · 关联问题 分数化小数

include<stdio.h>

int main() {

int a,b,c,res,e; int kase=0; double d=0.0; while(scanf("%d%d%d",&a,&b,&c)!=EOF && a && b && c) { e=a/b; printf("Case %d: %d.",++kase,e); res=a%b; for(int i=1;i<=c;i++) { res=res*10; printf("%d",res/b); res=res%b; } } return 0;

}

1班罗永辉 发表于 4个月前

少了换行,改成这样就能过了

#include<stdio.h> int main() { int a,b,c,res,e; int kase=0; double d=0.0; while(scanf("%d%d%d",&a,&b,&c)!=EOF && a && b && c) { e=a/b; printf("Case %d: %d.",++kase,e); res=a%b; for(int i=1;i<=c;i++) { res=res*10; printf("%d",res/b); res=res%b; if(i == c) printf("\n"); //多加一个换行符输出 } } return 0; }