我在 C 方面遇到的问题比我想象的要多。这段代码的目标是读取用户的输入,然后根据该整数输入“hello world”行该次数。我尝试了多种不同的方法,但每次我的代码只会执行 1 次。有什么建议吗?
#include <stdio.h>
int main()
{
double x;
printf("Enter a number from 1 to 5: ");
scanf("%f", &x);
for(int i =0; i <x; i++)
{
x= x-1;
printf ("Hello World.\n");
}
}