注册 登录
编程论坛 C++教室

简单问题

momo825 发布于 2008-04-10 17:55, 737 次点击
#include<iostream>
using namespace std;
double wendu();
int main()
{
    cout<<"Please enter a Celsius value:";
        double abc;
        cin>>abc;
    double h;
    h=wendu(abc);
    cout<<abc<<"degrees Celisus is="
        <<h<<"degrees Fahrenheit\n";
    return 0;
}
double wendu(double temp)
{
    return 1.8*temp+20;
}
为什么不能调用呢?错在哪?
8 回复
#2
sunkaidong2008-04-10 17:56
double wendu();看看你的声明
#3
momo8252008-04-10 18:05
不理解哦 麻烦帮忙改下- -
#4
sunkaidong2008-04-10 18:07
#include<iostream>
using namespace std;
double wendu(double );
int main()
{
    cout<<"Please enter a Celsius value:";
        double abc;
        cin>>abc;
    double h;
    h=wendu(abc);
    cout<<abc<<"degrees Celisus is="
        <<h<<"degrees Fahrenheit\n";
    return 0;
}
double wendu(double temp)
{
    return 1.8*temp+20;
}
#5
momo8252008-04-10 18:26
谢谢啊 麻烦这个哪错了?
#include<iostream>
using namespace std;
double guang(double);
int main()
{
    cout<<"Enter the number of light years:";
        double a;
    cin>>a;
    cout<<a<<"\n";
    cout<<a<<" "<<"light years=";
    double abc;
    abc=guang(a);
    cout<<abc<<"astronmical units";
    return 0;
}
void guang(double temp)
{
    return temp*63240;
}
#6
sunkaidong2008-04-10 18:33
看看基础...函数哪部分
#7
yijing212008-04-10 20:06
void返回。。记录值。。。楼主是该好好看下书先   这些最基础的东西  书上都有。
#8
xjywc2008-04-10 20:16
晕,楼主你的函数学的不怎么样啊,既然是void,那么没有返回值
#include<iostream>
using namespace std;
double guang(double);
int main()
{
    cout<<"Enter the number of light years:";
        double a;
    cin>>a;
    cout<<a<<"\n";
    cout<<a<<" "<<"light years=";
    double abc;
    abc=guang(a);
    cout<<abc<<"astronmical units";
    return 0;
}
double guang(double temp)   //错误的地方
{
    return temp*63240;
}
#9
momo8252008-04-10 20:30
偶晓得了- -偶初学菜鸟一个- -谢谢大家哦 偶会好好学的- -感觉编出来很有成就感啊呵
感觉像原来做很难的题一样...想了半天终于搞出来了...感觉很赞哦
1