// p03_03.cpp Sum of the 1st, 3rd, 6th, 10t, 15th, ... elements
// of a number sequence entered by the user.
#include <iostream>
using namespace std;

int main() {
float x, s =0;
int i = 0, iAdd = 1, diff = 1;
cout << "Add numbers followed by a nonnumeric character: \n";
while (cin >> x) {
 if (++i == iAdd) {
  s += x;
  iAdd += ++diff;
 }
}
cout << "Sum of 1st 3rd 6th 10th 15th ... numbers is " << s << endl;
return 0;
}
