求解答,非零整数的倒数
编写一个程序,计算用户输入非0整数的倒数,该程序应把计算的结果存储在double类型的变量中,再输出它#include<iostream>
using std::cout;
using std::endl;
using std::cin;
int main() {
int input=0;
cout<<"enter interger number:"<<endl;
cin >>input;
int output=1/input;
double reciprocal =static_cast<int>(output);
cout<<"the number you get reciprocal is :"<<endl;
cout<<reciprocal<<endl;
return 0;
}
以上这样是正确的吗???????????????