Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ab_x_cd_equal_to_ba_x_dc_v1.c
- Find the two-digit numbers that apply to:
- ab * cd = ba = dc
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- int main(void)
- {
- int a,b,c,d, counter=0;
- for(a=0; a<=9; a++)
- for(b=0; b<=9; b++)
- for(c=0; c<=9; c++)
- for(d=0; d<=9; d++)
- {
- if( (a*10+b)*(c*10+d) == (b*10+a)*(d*10+c) &&
- (a*10+b) > 9 &&
- (b*10+a) > 9 &&
- (c*10+d) > 9 &&
- (d*10+c) > 9 )
- {
- printf("\n %2d * %2d = %2d * %2d = %4d \n",
- a*10+b, c*10+d, b*10+a, d*10+c, (a*10+b)*(c*10+d) );
- counter++;
- }
- }
- printf("\n There are %d pairs of such numbers. \n", counter );
- return 0;
- } // main()
Add Comment
Please, Sign In to add comment