Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void is_divide3() {
- int value = 0;
- cout << "Введите целое число ";
- cin >> value;
- if (value % 3 == 0) {
- cout << value << " делится на 3";
- }
- else {
- cout << value << " не делится на 3";
- }
- cout << endl;
- }
- void sort_two() {
- int a, b;
- cin >> a;
- cin >> b;
- if (a > b) {
- cout << b << ", " << a << endl;
- }
- else {
- cout << a << ", " << b << endl;
- }
- }
- void sort_two2() {
- int a, b;
- cin >> a;
- cin >> b;
- if (a == b) {
- cout << "Равны " << a << endl;
- }
- else {
- if (a > b) {
- cout << b << ", " << a << endl;
- }
- else {
- cout << a << ", " << b << endl;
- }
- }
- }
- void test_goto() {
- cout << 1 << " ";
- cout << 2 << " ";
- goto label;
- cout << 3 << " ";
- label: cout << 4 << " ";
- cout << 5 << " ";
- cout << endl;
- }
- void test_cyclic_goto() {
- start: sort_two2();
- char ch;
- enter: cout << "Вы хотите повторить? (y/n)";
- cin >> ch;
- if (ch == 'y') {
- goto start;
- }
- if (ch == 'n') {
- return; // эта конструкция заканчивает выполнение функции
- }
- else {
- goto enter; // это безусловный переход
- }
- }
- bool disj(bool a, bool b) {
- return a || b;
- }
- bool conj(bool a, bool b) {
- return a && b;
- }
- bool imply(bool a, bool b) {
- return !a || b;
- }
- bool xnor(bool a, bool b) {
- return (a && b) || (!a && !b);
- }
- bool test_eq(bool a, bool b, bool c) {
- bool arg1 = imply(xnor(!a, !b), !c);
- bool arg2 = xnor(disj(!a, b), c);
- return imply(arg1, arg2);
- }
- void test_logic() {
- /*
- bool a = 0, b = 0;
- cout << a << " " << b << " | " << xnor(a, b) << endl;
- a = 0, b = 1;
- cout << a << " " << b << " | " << xnor(a, b) << endl;
- a = 1, b = 0;
- cout << a << " " << b << " | " << xnor(a, b) << endl;
- a = 1, b = 1;
- cout << a << " " << b << " | " << xnor(a, b) << endl;
- */
- bool a, b, c;
- cout << "a b c | eq" << endl;
- /*cout << a << " "
- << b << " "
- << c << " | "
- << test_eq(a, b, c) << endl;*/
- cout << "0, 0, 0 | " << test_eq(0, 0, 0) << endl;
- cout << "0, 0, 1 | " << test_eq(0, 0, 1) << endl;
- cout << "0, 1, 0 | " << test_eq(0, 1, 0) << endl;
- cout << "0, 1, 1 | " << test_eq(0, 1, 1) << endl;
- cout << "1, 0, 0 | " << test_eq(1, 0, 0) << endl;
- cout << "1, 0, 1 | " << test_eq(1, 0, 1) << endl;
- cout << "1, 1, 0 | " << test_eq(1, 1, 0) << endl;
- cout << "1, 1, 1 | " << test_eq(1, 1, 1) << endl;
- }
- bool is_body(double x, double y) {
- return (2.0 <= x) && (x <= 3.0)
- && (0.0 <= y) && (y <= 1.5);
- }
- void shooter() {
- double x;
- double y;
- cout << "Прицельтесь (введите x и y)" << endl;
- cin >> x >> y;
- bool body_x = (2.0 <= x) && (x <= 3.0);
- bool body_y = (0.0 <= y) && (y <= 1.5);
- bool head_x = (2.4 <= x) && (x <= 2.6);
- bool head_y = (1.5 <= x) && (x <= 1.7);
- bool body = body_x && body_y;
- bool head = head_x && head_y;
- if (body && head) {
- cout << "Бинго!!!" << endl;
- }
- else {
- cout << "Промах." << endl;
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- //cout << "Hello lesson 7\n";
- //test_logic();
- //test_goto();
- //is_divide3();
- shooter();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement