编辑代码

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

void test_diagnosis_progress() {
    float diagnosis_progress = 0.5; // 初始诊断进度为 0.5
    srand(time(NULL)); // 重新设置随机数种子
    // 模拟多次调用诊断进度的变化
    for (int i = 0; i < 10; ++i) {
        

        float fluctuation = (rand() % 7 - 3) / 100.0; // -0.03 到 +0.03 的随机数
        diagnosis_progress += fluctuation;

        // 确保诊断进度在 0 到 1 之间
        if (diagnosis_progress < 0) diagnosis_progress = 0;
        if (diagnosis_progress > 1) diagnosis_progress = 1;

        printf("Diagnosis Progress after iteration %d: %.2f\n", i + 1, diagnosis_progress);
    }
}

int main() {
    test_diagnosis_progress();
    return 0;
}