#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类型的,可实际出来的是整形的.