给出给定公式求值,但运行代码后按公式运算的结果总是0
#include<iostream>#include<cmath>
using namespace std;
int main()
{
long int a;
long int m, n;
cout << "请明确a为几:";
cin >> m;
cout << "请明确最后一个数是几位数:";
cin >> n;
a = (-20 / 81) * (1 - pow(10, n)) - (2 / 9) * n;
cout << "运算结果为:" << a;
}
各位大神帮忙看一看
按照我给定的求a的公式
当m,n都给赋值2的时候,应该是得24的啊,为什么运行代码得到的结果是0呢
请大神们指教 L:14:
-20 / 81 = 0;
2 / 9 = 0;
请先学习基础知识。
页:
[1]