知识库

C++语言开发示例:17. 多次输入

2025-02-01 20:26:57 李腾 1 次阅读

block.cpp

#include <iostream>

int main()
{
    using namespace std;
    cout << "The Amazing Accounto will sum and average ";
    cout << "five numbers for you.\n";
    cout << "Please enter five values:\n";
    double number;
    double sum = 0.0;
    for (int i = 1; i <= 5; i++)
    {
        cout << "Value " << i << ": ";
        cin >> number;
        sum += number;
    }
    cout << "Five exquisite choices indeed! ";
    cout << "They sum to " << sum << endl;
    cout << "and average to " << sum / 5 << ".\n";
    cout << "The Amazing Accounto bids you adieu!\n";
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:17. 多次输入

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!