[3.3 vertical problem]

Source: Internet
Author: User
Vertical Problem

Question:

Find all the formulas, such as ABC * de (three digits multiplied by two digits), so that in the complete vertical formula, all numbers belong to a specific number set. Set of input numbers (no space between adjacent numbers), and output all vertical bars. Each vertical column must have a number and an empty row. The total number of final output solutions. For the specific format, see the sample output (for the convenience of observation, the space in the vertical format is displayed with a decimal point, but your program should output a space instead of a decimal point ).

Sample input: 2357

Sample output:

<1>

.. 775

X .. 33

-----

. 2325

2325.

-----

25575

The number of solutions = 1

Question: [code = C/C ++] [/Code]

775 7, 5 in the {2, 3, 5, 7} collection
X 33 3 in the {2, 3, 5, 7} collection
-----------------------------------------------------
2325, 5 in the {2, 3, 5, 7} collection
2325
------------------------------------------------------
25575 2, 5, 7 in the {2, 3, 5, 7} collection

Enter a number to indicate that the array contains the elements of these numbers.

# Include <stdio. h> # include <string. h> int main () {int I, j, ABC, BC, C, Count, N, OK, K; char s [20]; char Buf [100]; scanf ("% s", S); Count = 0; for (I = 100; I <= 999; I ++) // The book starts from. I don't know why. For (j = 10; j <= 99; j ++) {abc = I * (J % 10); BC = I * (J/10 ); C = I * j; n = sprintf (BUF, "% d", I, j, ABC, BC, c); OK = 1; for (k = 0; k <strlen (BUF); k ++) if (strchr (S, Buf [k]) = NULL) OK = 0; If (OK) {printf ("<% d> \ n", ++ count ); printf ("% 5d \ NX % 4D \ n -------- \ n % 5d \ n % 4D \ n -------- \ n % 5d \ n", I, j, ABC, BC, c) ;}} printf ("the number of soulutions = % d \ n", count );}

Summary: The list is listed at a time. Learning. Srtchr (S, "C") function. Compares the position where character C appears in string s for the first time. Returns a pointer.

Constantly optimize the code and write easy-to-understand code. Welcome to the discussion.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.