【问题标题】:CLion IDE, inconsistent outputCLion IDE,输出不一致
【发布时间】:2016-05-03 22:20:39
【问题描述】:

我一直在 CLion IDE 上学习和编写 C 语言。我写了一个程序来计算我的课程成绩,但总是有不一致的输出。例如,有时输出会正确执行,有时 CLion 的终端会在屏幕上显示任何内容。但是,当我使用本机终端执行我的程序时,它总是可以正常工作。 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;
}

【问题讨论】:

  • 看到以后的正确输出,您确定这不是缓存 (c)make 构建的结果吗?在我看来,某些 printf 被忽略或程序在调用它们之前退出,没有设置错误退出状态...
  • 我总是在构建代码后运行,输出可能不同,肯定不稳定。启用编辑时也会自动重新加载 Cmake。
  • 您应该将文本作为文本发布,而不是图像和/或链接!
  • 为了更好地解释我的问题,我使用了输出图像。如果它们完全没有必要,我可以删除它们。

标签: c io output clion


【解决方案1】:

当前版本的 CLion 有几个终端输出问题,CLion 2016.1.2 Release Candidate 应该可以解决这些问题。

【讨论】:

  • 感谢您的信息,我以为我通过配置破坏了 CLion。
猜你喜欢
  • 2016-07-16
  • 2019-11-07
  • 2018-04-30
  • 2013-04-15
  • 2017-03-24
  • 1970-01-01
  • 2016-07-24
  • 2016-04-08
  • 2013-12-28
相关资源
最近更新 更多