fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector <double> a, b;
  7. double cur, sum = 0;
  8. while(cin >> cur){
  9. a.push_back(cur);
  10. sum += cur;
  11. }
  12. //Если последовательность состоит мене чем из двух элементов.
  13. if(a.size() < 2){
  14. cout << "The sequence must consist of at least two elements.";
  15. }
  16.  
  17. else{
  18. //Заполняем вектор b.
  19. for(int i=0; i < a.size(); ++i){
  20. b.push_back((sum - a[i])/(a.size() - 1));
  21. }
  22.  
  23. //Выводим ответ.
  24. cout << "The arithmetic average of all elements of this series except the element №i is:\n";
  25. for(int i=0; i < b.size(); ++i){
  26. cout << "for i = " << i+1 << ": " << b[i] << '\n';
  27. }
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 15240KB
stdin
2 3
stdout
The arithmetic average of all elements of this series except the element №i is:
for i = 1: 3
for i = 2: 2