about summary refs log tree commit diff
path: root/lang/cpptour/vecuser.cc
blob: 0eefb0e13d851ac543ffbb3e79939199ecf5a382 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <cmath>
#include <iostream>
#include <stdexcept>

#include "Vector.h"

using namespace std;

double
sqrt_sum (Vector& v)
{
  double sum = 0;
  for (int i = 0; i <= v.size(); ++i)
    try { sum += sqrt(v[i]); }
    catch (out_of_range) { cout << "Yeet!" << endl; }
  return sum;
}

int
main ()
{
  int n;
  cin >> n;
  Vector v (n);
  while (n--)
    cin >> v[n];
  cout << sqrt_sum (v) << endl;
}