我在使用用户输入问题的这个简单 for 循环中遇到了一些麻烦。问题要我创建一个表,将华氏度转换为摄氏度,使用 scanf 为表的起始值、结束值和增量值获取用户输入值。我只编码了 2 周,我刚刚开始循环,但这似乎应该有效。谢谢!这是我的代码:
#include <stdio.h>
int main (void)
{
int f, c, f_min, f_max, i;
printf("Enter the minimum (starting) temperature value: ");
scanf("%d", &f_min);
printf("Enter the maximum (ending) temperature value: ");
scanf("%d", &f_max);
printf("Enter the table increment value: ");
scanf("%d", &i);
for (f = scanf("%d", &f_min); f <= scanf("%d", &f_max); f = f + scanf("%d", &i))
{
c = ((f - 32.0) * (5.0 / 9.0));
// printf("Degrees in C is: %d");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)