0

我为实验室作业编写了下面的代码,但输出不是我所期望的。没有错误,但没有显示格式化的浮点数。有人可以解释我做错了什么吗?

任何帮助将不胜感激。

我的代码:

    /*Include files */
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>     

int main(void){    

    char patients[] = {'A', 'C', 'D', 'E', 'F', 'G'};
    float edvValues[] = {118.0, 120.0, 119.0, 122.0, 124.0, 121.0}; // Units of mL
    float esvValues[] = {48.0, 55.0, 52.0, 53.0, 50.0, 51.0}; // Units of mL
    float heartRateValues[] = {62.0, 80.0, 65.0, 70.0, 66.0, 64.0};
    
    for(int j = 0; j < sizeof(patients); j++){
            printf("Patient %c: ", patients[j]);
            printf("SV %d", (int)(edvValues[j] - esvValues[j]));
            printf(" CO %f L/min\n\r", (edvValues[j] - esvValues[j]) * heartRateValues[j]);
        }
    while(1);
}

这是预期的输出:

正确的输出

这是我的输出:

部分完成的代码忽略了格式化浮点数应该在的区域

4

0 回答 0