| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 735 人关注过本帖
标题:求个高手帮我看看程序35.36行错误在哪,纠结我一天了
只看楼主 加入收藏
jiweixiaoxia
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-5-22
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
求个高手帮我看看程序35.36行错误在哪,纠结我一天了
#include <stdio.h>
#include <math.h>
int main()
{
float norms (float);              //声明五个原函数 norms(标准身高),normswei(标准体重),percentwei(体重差额百分比)
float pcdif (float , float);      // pcdif(身高差额的百分比), showit(显示计算的结果)
void showit(float , float ,float ,float);
float normswei (float);
float percentwei (float, float);


int years, months;                //定义变量years ,months ,height ,normht ,age ,perdif
float height ,normht;
float age , perdif;
float weight;  //定义weight(体重)percentweight(体重差额)
float percentweight, normweight;

     /*这是输入部分*/   
printf("\n How old (in years) is this child? ");
scanf("%d", &years);
printf("How many months since the child's birthday? ");
scanf("%d",&months);

age = years + months/12.0;                      //年龄转换
printf("Enter the child's height (in inches): ");
scanf("%f" ,&height);

printf("Enter the chlid's weight (in kilogram): ");
scanf("%f",&weight);


    /*这是计算部分*/
normht = norms(age);
perdif = pcdif(height, normht);
normweight = normswei(age);
percentweight = percentwei(weight ,normweight);

showit(normht, perdif, normweight, percentweight);

 
    return 0;
}


/*下面是函数的占位函数*/
float norms  (float age)
{
    #define MINAGE 6.0
float agedif, avght;

agedif = age - MINAGE;
avght = -0.25*pow(agedif,2) + 3.5*agedif + 45.0;
return(avght);
}


float pcdif (float actual, float base)
{
return(actual - base)/base * 100.0;
}

float normweight(float age)
{
    float Norm;
    Norm=0.5*(age - 6)+5.0*(age - 6 ) + 48;
    return (Norm);
}


float percentweight(float actualwei, float normweights)
{
    return((actualwei - normweights)/normweights * 100.0);
}


void showit(float normht, float perdif, float normweight, float percentweight)
{
printf("\nThe average height in inches is: %5.2f\n", normht);
printf("The actual height deviates from the norm by: %6.2f%c",perdif,'%');
printf("\nThe average weight in kilogram is: %5.2f\n", normweight);
printf("The actual weight deviates from the norm by: %6.2f%c",percentweight,'%');   
}



35行和36行出问题了,编译提示说“undefined reference to'normswei(float)'”
可是我明明已经定义了
搜索更多相关主题的帖子: 标准体重 百分比 原函数 
2011-05-22 20:19
广陵绝唱
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:29
帖 子:3607
专家分:1709
注 册:2008-2-15
收藏
得分:10 
程序全复制上来了吗?看到函数声明,没看到函数本身啊.也许我眼花了,我再仔细找找.
2011-05-22 20:29
jiweixiaoxia
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-5-22
收藏
得分:0 
全贴上来了,函数在下面
2011-05-22 20:40
liangjinchao
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:376
专家分:697
注 册:2010-11-8
收藏
得分:10 
找了半天都没有找到normswei(float)的定义啊!难到眼花勒!

float norms  (float age)
{
    #define MINAGE 6.0
float agedif, avght;

agedif = age - MINAGE;
avght = -0.25*pow(agedif,2) + 3.5*agedif + 45.0;
return(avght);
}


float pcdif (float actual, float base)
{
return(actual - base)/base * 100.0;
}

float normweight(float age)
{
    float Norm;
    Norm=0.5*(age - 6)+5.0*(age - 6 ) + 48;
    return (Norm);
}


float percentweight(float actualwei, float normweights)
{
    return((actualwei - normweights)/normweights * 100.0);
}


void showit(float normht, float perdif, float normweight, float percentweight)
{
printf("\nThe average height in inches is: %5.2f\n", normht);
printf("The actual height deviates from the norm by: %6.2f%c",perdif,'%');
printf("\nThe average weight in kilogram is: %5.2f\n", normweight);
printf("The actual weight deviates from the norm by: %6.2f%c",percentweight,'%');   
}

[ 本帖最后由 liangjinchao 于 2011-5-22 21:08 编辑 ]

因为有了因为,所以有了所以,既然已成既然,何必再说何必
2011-05-22 21:06
jiweixiaoxia
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-5-22
收藏
得分:0 
原因找到了,是我大意了,把函数norswei和percentwei写成norweight和percentweight了正确的应该是:

float norsmwei(float age)
{
    float Norm;
    Norm=0.5*(age - 6)+5.0*(age - 6 ) + 48;
    return (Norm);
}


float percentwei(float actualwei, float normweights)
{
    return((actualwei - normweights)/normweights * 100.0);
}


void showit(float normht, float perdif, float normweight, float percentweight)
{
printf("\nThe average height in inches is: %5.2f\n", normht);
printf("The actual height deviates from the norm by: %6.2f%c",perdif,'%');
printf("\nThe average weight in kilogram is: %5.2f\n", normweight);
printf("The actual weight deviates from the norm by: %6.2f%c",percentweight,'%');   
}

2011-05-22 22:17
快速回复:求个高手帮我看看程序35.36行错误在哪,纠结我一天了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017803 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved