ex82135.cpp

来源:互联网 发布:淘宝企业店运营方案 编辑:程序博客网 时间:2024/05/21 19:27
 /**************************************************************************
PURPOSE:
BEGIN-TIME: 08/10/25    06:32
FINISH-TIME: 08/10/25    06:55
AUTHOR:    ch8_daniel
INPUT:    r ------ resistor
OUTPUT:    total ------ the total resistor
VERSION:    1.0
**************************************************************************/
 
#include <iostream>
 
using namespace std;
 
int main()
{
    float r = 0;
    float total = 0;
    
    cout << "Type '0' to quit inputting./n";
    
    while (1)
    {
        cout << "Enter r: ";
        cin >> r;
        
        if (r == 0)
        {
            break ;
        }
        
        total += 1 / r;
    }
    
    total = 1 / total;
    cout << "Total is : " << total << endl;
 
  return 0;
}
原创粉丝点击