Cod sursa(job #2972025)
Utilizator | Nanu Danu staiak | Data | 28 ianuarie 2023 16:23:33 |
---|---|---|---|
Problema | A+B | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <iostream>
#include <fstream>
#include "vector"
using namespace std;
int main() {
std::vector<int> numbers;
int number;
std::ifstream input("./adunare.in");
if(input.is_open()) {
while (input >> number) {
numbers.push_back(number);
}
input.close();
} else {
cout << "Unable to open the file";
}
int counter = 0;
for ( int i: numbers) {
counter = counter + i;
}
std::ofstream output("./adunare.out");
if (output.is_open()) {
output << counter;
output.close();
}
return 0;
}