课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759
【项目1】简单计算问题体验
- 输入底面半径r和高h,输出圆柱体的表面积。
样例输入:3.5 9
样例输出:Area = 274.889
参考解答:
#include <iostream> using namespace std; int main( ) { double r, h, area; cout << "输入半径: "; cin >> r; cout << "输入高: "; cin >> h; area = 2 * 3.1415926 * r * r + 2 * 3.1415926 * r * h; cout<<"圆柱体的表面积为:" << area << "\n"; return 0; }
- 有两个电阻R1和R2,求它们并联后的阻值R
参考解答:
#include <iostream> using namespace std; int main( ) { double r1, r2, r; cout << "输入要并联的两个电阻值: "; cin >> r1 >> r2; r = 1.0 / (1.0/r1 + 1.0/r2); cout<<"并联后的电阻值为:" << r << "\n"; return 0; }