标签: c++ variables math cmath
此代码在x = 1.9处停止,我该怎么做,以使while循环在2点处停止
#include <iostream> #include <cmath> using namespace std; int main() { double x, a = 1, b = 2, h = 0.1, y; x = a; while(x<=b) { y = sin(x); cout << x << " " << y << "\n"; x +=h; } return 0; }