I used to consider this problem when I judge a number of prizes. I didn't even consider it.
I am doing this today:
First define a data structure
Typedef stracut tagsush {
Int nsunshucount;
INT * SUSHUTEMP [MAX_SIZE]
}
Then define an instance of this structure
Add SUSHUTEMP [0] 2
NSUNSHUCOUNT Add 1
Then start from 3 to n to determine one by one
The method of judging is to remove the number of prime in the array. If you can do it, you will be skipped. If it doesn't finish, it will be a single digit, add it to an array.
In this way, we added all the numbers to the array.
Oh, it seems to be a little meaning! !