#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream we("we.txt");
int tab[10] = {};
for (int i = 0; i < 10; i++)
{
cout << "Podaj liczbe nr: " << i + 1 << ": ";cin >> tab[i];
we << tab[i] << "\n";
}
we.close();
int number, suma = 0;
ifstream we2("we.txt");
while(we2 >> number)
suma += number;
cout << endl;
we2.close();
ofstream wy("wy.txt");
wy << "Suma liczb z pliku we.txt wynosi: " << suma;
wy.close();
return 0;
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream we("we.txt");
int tab[10] = {};
for (int i = 0; i < 10; i++)
{
cout << "Podaj liczbe nr: " << i + 1 << ": ";cin >> tab[i];
we << tab[i] << "\n";
}
we.close();
int number, suma = 0;
ifstream we2("we.txt");
while(we2 >> number)
{
suma += number;
}
cout << endl;
we2.close();
ofstream wy("wy.txt");
wy << "Suma liczb z pliku we.txt wynosi: " << suma;
wy.close();
return 0;
}