习题2-6 排列

来源:互联网 发布:js验证手机号码 编辑:程序博客网 时间:2024/05/29 19:45
#include<stdio.h>#include<math.h>int main(){int a, b, c, d, e, f, g, h, i;for (int p = 123; p <= 329; p++){int n = p;a = n / 100;b = n / 10 % 10;c = n % 10;n *= 2;d = n / 100;e = n / 10 % 10;f = n % 10;n = n / 2 * 3;g = n / 100;h = n / 10 % 10;i = n % 10;for (int j = 1; j <= 9;j++)if (j != a&&j != b&&j != c&&j != d&&j != e&&j != f&&j != g&&j != h&&j != i)goto x1; printf("%d%d%d %d%d%d %d%d%d\n", a, b, c, d, e, f, g, h, i); x1:;}return 0;}

0 0
原创粉丝点击