#include<iostream>
double hanshu(double ly)
{
return 63240*ly;
}
int main()
{
using namespace std;
cout<<"enter the number of light years: ";
double ly1;
cin>>ly1;
double au1=hanshu(ly1);
cout<<ly1<<" light years = "<<au1<<" astronomical units."<<endl;
return 0;
}
已经定义了au1是double型,结果输出的是整形.