0
이것은 내가 작성한 것입니다. 나는 내 while
루프의 논리로 뭔가 있을지도 모른다고 생각하지만, 나는 그 사실을 발견 할 수 없다! 어떤 도움을 주셔서 감사합니다! 감사.이 프로그램을 실행할 때 왜 빈 테이블이 계속 나타 납니까?
#include <stdio.h>
#include <math.h>
//Open main function.
int main(void)
{
double new_area, area_total = 14000, area_uncut = 2500, rate = 0.02, years;
int count = 0;
printf("This program is written for a plot of land totaling 14000 acres, "
"with 2500 acres of uncut forest\nand a reforestation rate "
"of 0.02. Given a time period (years) this program will output a table\n"
"displaying the number acres reforested at the end of "
"each year.\n\n\n");
printf("Please enter a value of 'years' to be used for the table.\n"
"Values presented will represent the number acres reforested at the end of "
"each year:>> ");
scanf("%lf", &years);
years = ceil(years);
printf("\n\nNumber of Years\t\tReforested Area");
while (count <= years);
{
count = count + 1;
new_area = area_uncut + (rate * area_uncut);
printf("\n%1.0lf\t\t\t%.1lf", count, area_uncut);
area_uncut += new_area;
}
return 0;
}
어디에서 프로그램에서 멈 춥니 까 ..... while 루프에도 들어갈 수 있습니까? 다른 print 서술문을 추가하고 그런 식으로 디버그하십시오. –
'printf ("\ n % 1.0lf \ t \ t \ t % .1lf", count, area_uncut);''int' ('count') % lf', 이것은 정의되지 않은 행동입니다 ('% d'로 변경). –
while (count <= years);'-'는 빈 루프 본문을 만듭니다. 컴파일러에서 전체 경고를 켜면 경고해야합니다. – Barmar