Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, b, sum, squared, i, footnote;
- cout << "Enter the first value: ";
- cin >> a;
- cout << "Enter the second value: ";
- cin >> b;
- cout << endl;
- if (a < b) {
- cout << "The sacred string is: ";
- }
- else if (a == b) {
- cout << "The second value can be equal to the first one, but the result will be only if the value's square penultimate number will be 2." << endl << "The sacred string is: ";
- }
- else {
- cout << "Something wrong. The second value must be larger than or equal to the first one.\n\n";
- return 0;
- }
- sum = 0;
- squared = 0;
- for (a; a <= b; a++)
- {
- squared = pow(a, 2);
- for (i = 0; i < 2; i++)
- {
- if (squared % 10 == 2) {
- if (sum != 0) {
- cout << " + ";
- }
- sum = sum + a;
- cout << a;
- }
- squared = squared / 10;
- }
- }
- cout << " = " << sum << endl << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement