有0、1、2、4这4个数字,能组成多少个互不相同且个位、十位、百位数之和为4的三位数(各位可以相同)?都是多少? 输出格式为:先输出有多少个,再依次输出各个数
求助大佬有0、1、2、4这4个数字,能组成多少个互不相同且个位、十位、百位数之和为4的三位数(各位可以相同)?都是多少?
C语言输出格式为:先输出有多少个,再依次输出各个数,数之间以空格隔开。
2019-10-17 10:45
程序代码:#include <stdio.h>
int main( void )
{
for( unsigned i=4*4; i!=4*4*4; ++i )
{
unsigned a = (i/16)*4/3;
unsigned b = (i/4%4)*4/3;
unsigned c = (i%4)*4/3;
if( a+b+c == 4 )
printf( "%u%u%u\n", a, b, c );
}
}
2019-10-17 14:18
2019-10-17 15:39
2019-10-17 15:58
2019-10-17 16:17

2019-10-17 18:46
2019-10-17 22:08