#include #include using namespace std; int main1() { cout << "Hello, world..." << endl << "...and goodbye!"; // int 1abc; cout << 1 << ',' << 2.3 << "hello" << endl; cout << 2 + 3 << endl; // тук ще изведем 2 плюс 3 /* коментар на няколко реда */ cout << "2 + 3" << endl; double area; double radius; cout << "Моля, въведете радиуса: "; cin >> radius; area = 3.14 * radius * radius; // !!! area = "лице"; cout << "Л cout << r << endl;ицето е " << area << endl; int a = 5, b, c = 3; cout << a << ' ' << b << ' ' << c << endl; cout << "Hello,\nworld!\tGoodbye!\n"; cout << "Hi!\tGoodbye!\n"; // !!! d = 5; int d = 10; cout << d << endl; d = 15; // !!! int d = 15; cout << d << endl; d = 20; cout << d << endl; // !!! cin >> 3; // cout << 3 << (char)10 << 3; cout << 3 << 10 << 3 << endl; const double PI = 3.14; //!!! PI = 3.15; // !!! cin >> PI; bool p = true; bool q = false; bool r = p && !q; cout << r << endl; r = ((r && p) || q) && !(p || q); cout << r << endl; char ch = 'd'; ch = 65; cout << ch << endl; ch = -10; cout << ch << endl; cout << sizeof(a) << endl; short int x = 25; x = 40000; // !!! cout << x << endl; unsigned long u = 5; u = -10; // !!! cout << u << endl; x = -a; cout << a << ' ' << x << endl; return 0; } int main2() { int a, b; cout << "a = "; cin >> a; cout << "b = "; cin >> b; cout << a << " = " << a/b << '.' << b << " +" << a%b << endl; bool p = a <= b; // bool q = a = b; bool q = a != b; cout << p << ' ' << q << endl; cout << a << ' ' << b << endl; cout << 1234567.8 << ' ' << 0.000001234567 << endl; float f1 = 1.23456789; float f2 = 1.234567891234; double d1 = 1.23456789; double d2 = 1.234567891234; float zero = 1e-1000; cout << (f1 == f2) << endl; cout << (d1 == d2) << endl; cout << (zero == 0.0) << endl; float f = 1.8; f = f - 0.3; f = f - 0.3; f = f - 0.3; f = f - 0.3; f = f - 0.3; f = f - 0.3; const float EPS = 1E-6; cout << (f == 0) << endl; cout << f << endl; cout << (fabs(f) < EPS) << endl; f = 1.8; cout << f / 6 << endl; cout << 7 / 2.0 << endl; cout << (2 < 3 && 4 < 5) << endl; return 0; } int main() { bool b = false; char c = 'A'; short s = 1080; int i = 100000; float f = 1.3; double d = 5.78; // OK /* c = b; s = c; i = s; f = i; d = f; */ b = c; // загуба! всичко !=0 -> 1 cout << b << endl; c = s; // загуба! взема се %256 cout << c << endl; s = i; // загуба! взема се %32768 i = f; // загуба! взема се цяла част cout << i << endl; f = d; // загуба на точност! cout << 5 / (double)3 << endl; }