[Plain] Description
It was clearly because he was born in March 3, 1993. The year of his birth, the number of months and the date all had numbers 3. He thought that the number containing numbers 3 was his lucky number, he even liked the number of multiples of 3 and thought it was his lucky number. Now he gives a positive integer N. Please help us calculate the number between 1 and N (including 1 and N) there are several numbers that are clearly known as lucky ones.
Input
The input data has only one positive integer N (N <= 32767 ).
Output
The output data has only one integer, which is the number of lucky numbers between 1 and N.
Sample Input
10
Sample Output
3
Description
It was clearly because he was born in March 3, 1993. The year of his birth, the number of months and the date all had numbers 3. He thought that the number containing numbers 3 was his lucky number, he even liked the number of multiples of 3 and thought it was his lucky number. Now he gives a positive integer N. Please help us calculate the number between 1 and N (including 1 and N) there are several numbers that are clearly known as lucky ones.
Input
The input data has only one positive integer N (N <= 32767 ).
Output
The output data has only one integer, which is the number of lucky numbers between 1 and N.
Sample Input
10
Sample Output
3
[Plain] # include <stdio. h>
Int check (int num );
Int main ()
{
Int I;
Int count;
Int num;
Count = 0;
Scanf ("% d", & num );
For (I = 1; I <= num; I ++)
{
If (I % 3 = 0)
{
Count ++;
}
Else if (check (I ))
{
Count ++;
}
}
Printf ("% d", count );
}
Int check (int num)
{
Int flag = 0;
While (num)
{
If (num % 10 = 3)
{
Flag = 1;
}
Num/= 10;
}
Return flag;
}
# Include <stdio. h>
Int check (int num );
Int main ()
{
Int I;
Int count;
Int num;
Count = 0;
Scanf ("% d", & num );
For (I = 1; I <= num; I ++)
{
If (I % 3 = 0)
{
Count ++;
}
Else if (check (I ))
{
Count ++;
}
}
Printf ("% d", count );
}
Int check (int num)
{
Int flag = 0;
While (num)
{
If (num % 10 = 3)
{
Flag = 1;
}
Num/= 10;
}
Return flag;
}