int main(无效) { double height_in_meters; double inch_portion_of_height; double foot_portion_of_height; printf(" Height Convertion Program\\\" "在屏幕上显示结果。必须以公制单位输入并包含小数部分才能输入。 " \ n" "答案将以整个英尺显示,并且 inches.\\\\ n); 做{ printf(以米为单位输入此人的身高:); fflush(stdout); scanf("%lf",& height_in_meters); if(height_in_meters< = 0) printf("我们只处理有高度的人> 0.(\\ nn); } while(height_in_meters< = 0); inch_portion_of_height = height_in_meters * 100 / FACTOR; foot_portion_of_height = floor(inch_portion_of_height / 12); inch_portion_of_height - = 12 * foot_portion_of_height; printf(" \ n height is equivilant to%。0f''%。0f\"。\ n", foot_portion_of_height,inch_portion_of_height); 返回0; } leaving off those semicolons will kill you. It is conventional to useall uppercase only in naming macros. Try seeing if you can tell what''s happening here: #include <stdio.h>#include <math.h> #define FACTOR 2.54 int main(void){ double height_in_meters;double inch_portion_of_height; double foot_portion_of_height;printf("Height Convertion Program\n""Designed by Randolph Gibson - 15 january 2001\n""Coded by Rome Baker - September 2005\n\n""This program will convert a person''s height from meters\n""into feet and inches (rounded to the nearest inch) and \n""display the result on the screen. The height must be\n""entered in metric units and contain decimal portions.\n""The answer will be displayed in whole feet and ""inches.\n\n"); do {printf("Enter the person''s height in meters: ");fflush(stdout);scanf("%lf", &height_in_meters);if (height_in_meters <= 0)printf("We deal only in people with heights > 0.\n");} while (height_in_meters <= 0); inch_portion_of_height = height_in_meters * 100 / FACTOR;foot_portion_of_height = floor(inch_portion_of_height / 12);inch_portion_of_height -= 12 * foot_portion_of_height; printf("\nThe height is equivilant to %.0f''%.0f\".\n",foot_portion_of_height, inch_portion_of_height); return 0;} 这篇关于我是新来的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-18 18:26