http://www.runoob.com/cprogramming/c-exercise-example1.html
题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
代码如下:
#include <stdio.h>
int main()
{
int a,b,c,count=0;;
for(a=1;a<=4;a++)
{
for(b=1;b<=4;b++)
{
for(c=1;c<=4;c++)
{
if(a!=b && a!=c && b!=c){
count++;
printf("%d\n",a*100+b*10+c*1);
}
}
}
}
printf("%d",count);
}
结果:
123
124
132
134
142
143
213
214
231
234
241
243
312
314
321
324
341
342
412
413
421
423
431
432
24
本文通过C语言程序解决了一个数学问题:使用数字1、2、3、4可以组成多少个不同的无重复数字的三位数,并列举了所有可能的组合。
5879

被折叠的 条评论
为什么被折叠?



