采用C语言:输出身高和标准身高的对照表,身高范围和间隔距离可输入,假设标准(身高-80)*0.7和(身高-80)*0.6分别为男女标准体重。最终实现的效果如图所示:
代码如下:
int main()
{
int low, high, add;//定义身高上下限与增长间距
int i, j=0;
int sex,flag;//性别选择与报错标志位
int count, count2;//定义要输出的表格单元数量
double weight;//定义体重
do
{
flag = 0;
printf("Please choose the gender(male is 1,female is 0):");
scanf("%d", &sex);//选择性别
printf("\nPlease enter the lower limit of hight(cm):");
scanf("%d",&low);//输入身高下限
printf("\nPlease enter the higher limit of hight(cm):");
scanf("%d", &high);//输入身高上限
printf("\nPlease enter the clearance of hight(cm):");
scanf("%d",&add);//输入增长间距
if (add<=0 || low>=high || low<=0 || (sex!=0 && sex