if testisquare idigits false if testisquare idigits continue for int j i 1 j

If testisquare idigits false if testisquare idigits

This preview shows page 1 - 2 out of 2 pages.

* if (test(i_square, i_digits) == false) */ if (!test(i_square, i_digits)) continue; for (int j = i + 1; j <= max; ++j) { const int j_square = j * j; /* Declares an array of 10 ints. */ int i_and_j_digits[10]; for (int dig = 0; dig < 10; ++dig) i_and_j_digits[dig] = i_digits[dig]; /* Tests whether all digits that occur in j_square are distinct, * not equal to 0, and do not occur in i_square. * Next line could also be written as follows. * if (test(j_square, i_and_j_digits) == false) */ if (!test(j_square, i_and_j_digits)) continue; for (int k = j + 1; k <= max; ++k) { const int k_square = k * k; /* Declares an array of 10 ints. */ int i_and_j_and_k_digits[10]; for (int dig = 0; dig < 10; ++dig) i_and_j_and_k_digits[dig] = i_and_j_digits[dig]; /* Tests whether all digits that occur in k_square are distinct, * not equal to 0, and do not occur in either i_square or j_square. * Next line could also be written as follows. * if (test(k_square, i_and_j_and_k_digits) == false) */ if (!test(k_square, i_and_j_and_k_digits)) continue;
Image of page 1

Subscribe to view the full document.

/* Tests whether every nonnull digit occurs in one of the three squares. */ int dig = 0; /* Next line could also be written as follows. * dig = dig + 1; * while (dig < 10) */ while (++dig < 10) if (i_and_j_and_k_digits[dig] == 0) break; if (dig == 10) { ++nb_of_solutions; printf("%-3d %-3d %-3d\n", i_square, j_square, k_square); } } } } if (nb_of_solutions == 0) { printf("No solution has been found, which is suspicious.\n");
Image of page 2
  • Fall '19
  • 11

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes