1 /* 2 求符合给定条件的整数集 3 */ 4 5 #include <stdio.h> 6 7 int main() 8 { 9 int n; 10 int cnt = 0; 11 int hundred, ten, unit; 12 13 scanf_s("%d", &n); 14 15 for (int i = 100; i < 1000; i++) 16 { 17 hundred = i / 100; 18 ten = i % 100 / 10; 19 unit = i % 10; 20 21 if (hundred == ten || ten == unit || hundred == unit) 22 { 23 continue; 24 } 25 26 if (hundred >= n && hundred <= n+3) 27 { 28 if (ten >= n && ten <= n + 3) 29 { 30 if(unit >= n && unit <= n + 3) 31 { 32 printf("%d", i); 33 cnt++; 34 if (cnt < 6) 35 { 36 printf(" "); 37 } 38 else 39 { 40 if (cnt == 6) 41 { 42 printf("\n"); 43 cnt = 0; 44 } 45 } 46 } 47 } 48 } 49 } 50 51 return 0; 52 }
原文地址:https://www.cnblogs.com/2018jason/p/10950660.html
时间: 2024-11-09 02:10:35