CLion IDE,输出不一致

标签 c io output clion

我一直在 CLion IDE 上学习和编码 C 语言。我写了一个程序来计算我的类(class)成绩,但输出结果总是不一致。例如,有时输出会正确执行,有时 CLion 的终端会在屏幕上显示任何内容。但是,当我使用 native 终端执行我的程序时,它总是可以正常工作。 CLion 有什么问题?

这是我的代码:

#include <stdio.h>
double essay_calc(double grd1, double grd2, double grd3)
{
    double sum1, sum2, sum3, result;

sum1 = (100*(grd1) / 22.0);
sum2 = (100*(grd2) / 22.0);
sum3 = (100*(grd3) / 22.0);

result = ((sum1*1.10) - sum1 + (sum2*1.15) - sum2 + (sum3*1.20) - sum3);

return (result);
}
double presentation(double pre1, double pre2)
{
    double sum1, sum2, result;

sum1 = (100*(pre1))/23.0;
sum2 = (100*(pre2))/40.0;

result = ((sum1 + sum2)/2)/5;

return (result);
}
double hw(double grd1)
{
    return ((grd1*15)/100.0);
}
int main(void)
{
    double ess_grd1, ess_grd2, ess_grd3, pre_grd1, pre_grd2, hw_grd;
    double total, essay, present, howork;

printf("Enter 3 essay grades: ");
scanf("%lf %lf %lf", &ess_grd1, &ess_grd2, &ess_grd3);
printf("\nEnter 2 presentation grades: ");
scanf("%lf %lf", &pre_grd1, &pre_grd2);
printf("\nEnter 1 HW grade: ");
scanf("%lf", &hw_grd);

essay = essay_calc(ess_grd1, ess_grd2, ess_grd3);
present = presentation(pre_grd1, pre_grd2);
howork = hw(hw_grd);

total = (essay + present + howork);

printf("\nEssays: %.2f\n", essay);
printf("Presentations: %.2f\n", present);
printf("Homeworks: %.2f\n", howork);
printf("Total: %.2f\n", total);

if(total < 70)
    printf("You have to get %.2f points from final exam to pass\n", 70 - total);
else
    printf("Your grade is already over C\n");


return 0;
}

最佳答案

当前版本的 CLion 在终端输出方面存在一些问题,CLion 2016.1.2 Release Candidate应该解决这些问题。

关于CLion IDE,输出不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37015375/

相关文章:

c - 简单的链表程序不起作用

c++ - 字符串大小始终为 32 字节

c++ - 输出未按正确顺序打印

R:如何将结果合并为唯一的输出?

c - 在C中,如何区分未初始化的指针和空指针?

c - 如何在 C 中将图像转换为 base64?

检查某个 USB 闪存是否连接到我的系统

java - 如何查明从流中读取了多少个字符或字节?

c++ - 用于独立于平台的二进制文件 I/O 的 C/C++ 库

Luigi Python 中的 MongoDB