📄 triples.cpp
字号:
// triples.cpp
//计算1-100范围内满足沟谷定律的整数.
//多重循环的使用。
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int count = 0;
long hyptSquared; // hypotenuse squared(直角三角形斜边的平方)
long sidesSquared; // sides squared(斜边的平方和)
for ( /* write header for side1 */ ) {
for ( /* write header for side2 */ ) {
for ( /* write header for hyptSquared */ ) {
/* calculate hyptSquared */
/* calculate the sum of the sides squared */
if ( hyptSquared == sidesSquared ) {
cout << side1 << "\t" << side2 << "\t"
<< hypt << "\n";
++count;
} // end if
} // end for
} // end for
} // end for
cout << "A total of " << count << " triples were found."
<< endl;
system("PAUSE");
return 0;
} // end main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -