?? 4-7.cpp
字號:
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<double> store;
double x;
typedef vector<double>::size_type vec_sz;
while(cin>>x)
store.push_back(x);
vec_sz size;
size=store.size();
if(size==0)
throw domain_error("an empty vector!");
sort(store.begin(),store.end());
vec_sz mid=size/2;
double average=size%2==0?(store[mid]+store[mid-1])/2:store[mid];
cout<<"The average is: "
<<average<<endl;
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -