#include<iostream> using namespace std; int main() { int n=1; double s=0; do//先执行一次循环体 { s=s+(1.0/n); n++; }while(s<8.0); cout <<"s="<<s<<endl; cout <<"n="<<n<<endl; return 0; }
#include<iostream> using namespace std; int main() { int n=1; double s=0; do//先执行一次循环体 { s=s+(1.0/n); n++; }while(s<8.0); cout <<"s="<<s<<endl; cout <<"n="<<n<<endl; return 0; }