Untitled
unknown
c_cpp
a month ago
738 B
1
Indexable
Never
#include <iostream> #include <fstream> using namespace std; int main() { ifstream inputFile("promienie.txt", ios::in); ofstream outputFile("wyniki.txt", ios::out); double r1, r2; if (inputFile.is_open()) { inputFile >> r1 >> r2; inputFile.close(); } else { cout << "Blad odczytu pliku promienie.txt!" << endl; return -1; } double field1 = 3.14 * r1 * r1; double field2 = 3.14 * r2 * r2; if (outputFile.is_open()) { if (field2 < field1) { outputFile << field2 << '\n' << field1; } else { outputFile << field1 << '\n' << field2; } outputFile.close(); } else { cout << "Blad zapisu pliku wynik.txt!" << endl; return -1; } return 0; }
Leave a Comment