Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int coef{ 12 };
- float x{0};
- int a{ 10 };
- int b{ 3 };
- int num{ 125 };
- int d1{ 0 };
- int d2{ 0 };
- int d3{ 0 };
- int z{ 0 };
- //z = a % b; // a - ((a / b) * b) => 10 - ( (10 / 3) * 3) => 1
- //z = z + 5; z += 5;
- //z = z * b; z *= b;
- //a = a / b; a /= b;
- //z = z % a; z %= a;
- //z = z - b; z -= b;
- //z = z + 1; z += 1; z++; ++z;
- //z = z - 1; z -= 1; z--; --z;
- std::cout << "Enter 3 digit number\n";
- std::cin >> num;
- d1 = num % 10; // 125 - ((125 / 10) * 10) => 125 - 120 = > 5;
- num /= 10; // 125 / 10 -> num; n <- 12
- d2 = num % 10; // 12 - (( 12 /10) * 10) => 12 -10 => 2;
- num /= 10; // 12 / 10 - > num; num <- 1
- d3 = num % 10; // 1 - (( 1 / 10) * 10) -> 1;
- num /= 10; // 1 / 10 -> num; num <- 0;
- std::cout << "d1 = " << d1 << " d2 = " << d2 << " d3 = " << d3 << " num = " << num << '\n';
- //std::cout << "z++ " << (z++) << '\n';
- //std::cout << "z= " << (z) << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment