herrDeng網內搜尋

自訂搜尋

Ads

2017年3月14日 星期二

Ex3 算zeta(2) & π

sum=1/1^2+1/2^2+1/3^2+1/4^2+.........+1/n^2+......

並計算 sqrt(6*sum)

33 則留言:

B10333070徐承瑋 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main() {

cout<<"pi\n";
cout<<"Input n=";
unsigned n;
cin>>n;
double sum=0;
for(int i=1;i<=n;i++){
sum=sum+1/((double)i*i) ;
}
cout<<"ans>>"<<sqrt(6*sum)<<endl;
system("Pause");
return 0;
}

B10333107 曾詠浩 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
cout << "pi......\n";
cout << "Input n=";
unsigned n;
double sum=0;
cin >>n;
cout << n<<endl;
for(int i=1;i<=n;i++)
{
sum=sum+1/((double)i*i);
}
cout <<sqrt(6*sum);
system("Pause");
return 0;
}

B10333005 陳於農 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
cout << "Compute pi......\n";
cout << "Input n=";
unsigned n;
double sum=0;
cin >> n;
cout << n << endl;
for (int i=1;i<=n;i++)
{
sum = sum+1/((double)i*i);
}
cout << sqrt(6*sum);
system("Pause");
return 0;
}

b10333097胡聖恩 提到...

#include<iostream>
#include<cstdlib>
#include<cmath>

using namespace std;

int main()

{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);

}
cout << sqrt(6 * sum);
system("Pause");
return 0;

}

B10333064王韻菱 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;
int main()
{
cout << "Compute pi...\n";
cout << "Input n=";
double sum = 0;
unsigned n;
cin >> n;
cout << n << endl;
for (int i=1;i<=n;i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6*sum);
system("Pause");
return 0;
}

b10333080王育文 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
unsigned n;
cin >> n;
cout << n<<endl;

double sum=0;
for (int i = 1; i <= n; i++)
{
sum +=1/((double)i*i);
}

cout << sqrt(6*sum);

system("Pause");
return 0;
}

b10333079 提到...

#include<iostream>
#include<cstdlib>
#include<cmath>

using namespace std;

int main()
{
unsigned n;
cout << "Compute pi.......\n";
cout << "Input n=";
double sum = 0;

cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{

sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;



}

B10333079 葉禮魁 提到...

#include<iostream>
#include<cstdlib>
#include<cmath>

using namespace std;

int main()
{
unsigned n;
cout << "Compute pi.......\n";
cout << "Input n=";
double sum = 0;

cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{

sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;



}

B10333089 游智翔 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
cout << "Compute pi....\n";
cout << "Input n=";
unsigned n;
cin >> n;
double sum = 0;
for (int i = 1; i <= n; i++) {
sum = sum + 1 / double(i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}

B10333106 劉郁芃 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
double sum = 0;
unsigned n;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}

B10333077 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;
int main()
{
cout << "Compute pi.......\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}

B10433038詹恭煒 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("pause");
return 0;
}

B10433053謝肇安 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>
using namespace std;

int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "π=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec\n";
system("pause");
return 0;
}

b10333083周琬芸 提到...

#include <iostream>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<ctime>
using namespace std;
int main(){
cout << "Compute pi .....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
for (int i=1;i<=n;i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << sqrt(6 * sum)<<endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec \n";
system("Pause");
return 0;


}

B10333027 毛冠霖 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
cout << "pi......\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("pause");
return 0;
}

B10333055 翁恩義 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>

using namespace std;

int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << setprecision(16) << "zata(2)=" << sum << endl;
cout <<sqrt(6*sum) << endl;

end = clock();
cout << (end - begin) / 1000.0 << "sec\n";
system("Pause");
return 0;
}

b10333094張之銜 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Iput n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i<=n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;

b10333142 提到...

#include
#include
#include
#include
#include

using namespace std;

int main()
{
cout << "input n=";
unsigned n; cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
for (int i=1; i<=n;i++)
{
sum += 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "%=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec/n";
system("Pause");
return 0;
}

B10333086 陳晏堂 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>
using namespace std;

int main()
{
cout<< "pi........\n";
cout<< "Input n=";
unsigned n;
double sum=0;
cin>>n;
cout<<n<<endl;
unsigned begin=clock(),end;
for(int i=1;i<=n;i++)
{
sum=sum+1.0/((double)i*i);
}
cout <<sqrt(6*sum);
system("pause");
return 0;
}

B10433156 提到...

#include<iostream>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<ctime>
using namespace std;

int main()
{

cout << "Compute Pi......\n ";
cout << "Input n=";
cin >> n;
unsigned n;
double sum = 0;
for (int i = 1; i <= n; i++)
sum += 1.0 / ((double)i*i);
cout << setprecision(16) << "zeta(2)" << sum << endl;
cout << Pi << sum << endl;
end = clock();
cout << (end - begin / 1000.0 <<"sec\n")
system("Pause");
return 0;

}

B10333063羅胤銓 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin =clock(), end;
double sum = 0;
for (int i = 1; i <= n; i++)
{
sum += + 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zera(2)=" << sum << endl;
cout << "π="<< sqrt(6 * sum)<<endl;
end = clock();
cout << (end - begin) / 1000.0 << " sec\n";
system("Pause");
return 0;
}

b10133187 提到...

#include
#include
#include

using namespace std;

int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}

b10133187 提到...

#include
#include
#include

using namespace std;

int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}

b10133187 提到...

#include
#include
#include

using namespace std;

int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}

b10133187 提到...

#include
#include
#include

using namespace std;

int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}

b10133187 提到...

#include
#include
#include

using namespace std;

int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}

b10133187 提到...

#include
#include
#include

using namespace std;

int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}

B10333072 黃玟茜 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;


double sum = 0;
for (int i = 1; i <= n; i++) {
sum += 1 / ((double)i*i);

}
cout << sqrt(6 * sum); sfas



system("Pause");
return 0;
}

B10333053 梁竣翔 提到...

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>

using namespace std;

int main()
{
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum=0;

for (int i = 1; i <= n ; i++)
sum += 1.0 / ((double)i*i);
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "π=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec\n";
system("Pause");
return 0;
}

b10333142 提到...

#include
#include
#include
#include
#include


using namespace std;
#include
int main()
{
cout << "input n=";
unsigned n; cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
#pragma omp parallel for reduction(+ : sum)
for (int i=1; i<=n;i++)
{
sum += 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "%=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec/n";
system("Pause");
return 0;
}

b10233032謝翔宇 提到...

#include
#include
#include
using namespace std;
int main() {

cout<<"pi\n";
cout<<"Input n=";
unsigned n;
cin>>n;
double sum=0;
for(int i=1;i<=n;i++){
sum=sum+1/((double)i*i) ;
}
cout<<"ans>>"<<sqrt(6*sum)<<endl;
system("Pause");
return 0;
}

b10233032謝翔宇 提到...

#include
#include
#include
using namespace std;
int main() {

cout<<"pi\n";
cout<<"Input n=";
unsigned n;
cin>>n;
double sum=0;
for(int i=1;i<=n;i++){
sum=sum+1/((double)i*i) ;
}
cout<<"ans>>"<<sqrt(6*sum)<<endl;
system("Pause");
return 0;
}

B10333053 梁竣翔 提到...

#include
#include
#include
#include
#include

using namespace std;
#include
int main()
{
cout << "input n=";
unsigned n; cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
#pragma omp parallel for reduction(+ : sum)
for (int i=1; i<=n;i++)
{
sum += 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "%=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec/n";
system("Pause");
return 0;
}

Related Posts Plugin for WordPress, Blogger...

熱門文章