浮点型不能直接使用%计算余数,只能自己模拟,代码如下:
#include <stdio.h> int main() { float a,b; scanf("%f%f",&a,&b); while(a>=b) { a-=b; } printf("%f",a); return 0; }