#38362: c 基礎寫法


q0908309831@gmail.com (浪人飄飄)


#include <stdio.h>
#include <stdlib.h>


int main() {
    
    int times = 0;
    scanf("%d", &times);
    for (int j = 0; j < times; j++) {
        double out, in = 0.0;
        double rate = 0.0;
        char c = '%';
        scanf("%lf %lf", &out, &in);

        rate = (in - out) / out;
        if (rate >= 0) rate += 0.0000001;
        else rate -= 0.0000001;

        rate *= 100;
        printf("%.2lf%c ", rate, c);


        if (rate < 10 && rate > -7) printf("keep\n");
        else printf("dispose\n");

    }


    return 0;
}

避免循環小數所加的0.000001,位數記住不要太少,不然有些測資會進位