Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void is_good_name() {
- char ch = '$';
- cin >> ch;
- cout << ch << " - " << (int)ch << endl;
- int id = 46;
- cout << id << " - " << (char)id << endl;
- /*
- id = (int)ch;
- bool h1 = (id == 95);
- bool h2 = (65 <= id && id <= 90);
- bool h3 = (97 <= id && id <= 122);
- */
- bool h1 = (ch == '_');
- bool h2 = ('A' <= ch && ch <= 'Z');
- bool h3 = ('a' <= ch && ch <= 'z');
- if ( h1 || h2 || h3) {
- cout << "good\n";
- }
- else {
- cout << "bad\n";
- }
- }
- void calculator() {
- cout << "Enter expression: a + b.\n";
- double x, y;
- char op;
- cin >> x >> op >> y;
- if (op == '+') {
- cout << x << " + " << y << " = "
- << x + y << endl;
- }
- else if (op == '-') {
- cout << x << " - " << y << " = "
- << x - y << endl;
- }
- else if (op == '*' || op == 'x') {
- cout << x << " x " << y << " = "
- << x * y << endl;
- }
- else if (op == '/' || op == ':') {
- if (y != 0) {
- cout << x << " : " << y << " = "
- << x / y << endl;
- }
- else {
- cout << "Division by zero\n";
- }
- }
- else if (op == '^') {
- cout << x << " ^ " << y << " = "
- << pow(x, y) << endl;
- }
- else {
- cout << "Bad operator\n";
- }
- }
- void calculator2() {
- cout << "Enter expression: a + b.\n";
- double x, y;
- char op;
- cin >> x >> op >> y;
- switch (op) {
- case '+':
- cout << x << " + " << y
- << " = " << x + y;
- break;
- case '-':
- cout << x << " - " << y
- << " = " << x - y;
- break;
- case '*':
- cout << x << " x " << y
- << " = " << x * y;
- break;
- case ':':
- case '/':
- cout << x << " / " << y
- << " = " << x / y;
- break;
- }
- }
- void task() {
- int y = { 10.5 };
- int x{};
- if (x > 15) {
- x = 14;
- cout << "Var 1\n";
- if (x < 18) {
- if (x > 22) {
- cout << x;
- }
- }
- }
- else {
- cout << "Var 2\n";
- if (x > 18) {
- if (x > 22) {
- if (x > 33) {
- cout << "Hoh " << x << endl;
- }
- }
- }
- }
- }
- int main() {
- //is_good_name();
- //calculator2();
- task();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement