当条件为“ true”时,while循环停止

时间:2018-10-26 14:14:04

标签: 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;
}

0 个答案:

没有答案
相关问题