Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <limits>
- #include <cmath>
- #include <stdlib.h>
- using namespace std;
- class SqrtException {};
- static void first() {
- double a = -99, b = -99, per, area;
- cout << "\na, b, c, d: ";
- while (true) {
- cin >> a;
- if (!cin) {
- cin.clear();
- cout << "error" << endl;
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- else {
- break;
- }
- }
- while (true) {
- cin >> b;
- if (!cin) {
- cout << "error";
- cin.clear(); // يà ٌëَ÷àé, هٌëè ïًهنûنَùèé ââîن çàâهًّèëٌے ٌ îّèلêîé
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- else {
- break;
- }
- }
- per = 2 * (a + b);
- area = a * b;
- ofstream fout("lab8.txt");
- cout << setfill('#') << setprecision(5) << setw(15) << per << "\n";
- cout << setfill('#') << setprecision(5) << setw(15) << area;
- fout << setfill('#') << setprecision(5) << setw(15) << per << "\n";
- fout << setfill('#') << setprecision(5) << setw(15) << area;
- fout.close();
- }
- static void second() {
- double x;
- cout << "\n x: ";
- while (true) {
- cin >> x;
- if (!cin) {
- cout << "error";
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- }
- else {
- try {
- if (x <= 8) {
- throw SqrtException();
- }
- else
- break;
- }
- catch (SqrtException & s) {
- cout << "x > 8.\n";
- }
- }
- }
- cout << 12 * x + sqrt(x - 8);
- }
- int main() {
- cout << "//زا:\n//1.\tLp and Spr.\n"
- "//2.\tS= ." << endl;
- first();
- second();
- return 0;
- }
Add Comment
Please, Sign In to add comment