Title: An odd number of 0-7 can be composed.
Algorithm idea:
This problem is actually a permutation of the problem, set the number of SUN=A1A2A3A4A5A6A7A8,A1-A8 to represent this number of a bit of the value,
When the last digit of a number is odd, it must be an odd number, no matter what number is in front of it. If the last digit is an even number,
The number must be even.
A1-a8 can take 0-7 of this eight number, the first number is not 0.
From this number to one count to the number of 8 digits to start counting odd numbers:
1. When only one digit is the last of the number, the odd number is 4
2. When the number is two digits, the odd number is 4*7=28
3. When the number is three digits, an odd number is: 4*8*7=224
。
。
。
8. When the number is eight digits, the odd number is: 4*8*8*8*8*8*8*7 (the last one to the first digit)
C Language Program code:
1#include <stdio.h>2 intMainintAGRC,Char*agrv[])3 {4 Longsum =4, S =4;//the initial value of sum is 4, and only one digit is an odd number of 45 intJ;6 for(j =2; J <=8; J + +)7 { 8printf"the number of%d digits is odd%ld\n", J-1, s);9 if(J <=2)TenS *=7; One Else AS *=8; -Sum + =s; - } theprintf"the number of%d digits is odd%ld\n", J-1, s); -printf"The total number of odd numbers is:%ld\n", sum); -System"Pause"); - return 0; +}
C-language classical algorithm-the odd number of 0-7 can be composed