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.