📄 program_4_7.cpp
字号:
// Program 4.7: Computes average of a list of values
#include <iostream>
using namespace std;
int main() {
cout << "Please enter list of numbers," << endl
<< "type Ctrl + Z to end" << endl;
int ValuesProcessed = 0;
float ValueSum = 0;
float Value;
while (cin >> Value) {
ValueSum += Value;
++ValuesProcessed;
}
if (ValuesProcessed > 0) {
float Average = ValueSum / ValuesProcessed;
cout << "Average: " << Average << endl;
}
else
cout << "No list to average" << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -