手记

c plus plus作业二题三

include "stdafx.h"
include<iostream>
include<cmath>
include<iomanip>

using namespace std;

int main()
{
int term;
double pi=0;
cout << "term" << setw(29) << "pi"<<endl;
for (term=1; term <= 1000; term++)
{
pi = pi + pow(-1, term + 1) 4 / (2 term - 1);

    cout <<setw(31)<<setiosflags(ios::left)<< term <<showpoint<<setprecision(9)<< pi << endl;

}
return 0;

}

0人推荐
随时随地看视频
慕课网APP