// test20.cpp : 定义控制台应用程序的入口点。
//
include "stdafx.h"
include
include
include
include
include
include
include<string.h>
include
using namespace std;
class Solution {
public:
int NumberOf1Between1AndN_Solution(int n)
{
// int num=1;
int count = 0;
for (int i = 0;i <= n;i++)
{
int num = i;
do {
if (num % 10 == 1)
{
++count;
}
num = num / 10;
} while (num!=0);
}
return count;
}
};
int main()
{
Solution so;
//int count=so.NumberOf1Between1AndN_Solution(13);
cout <<"count:" << so.NumberOf1Between1AndN_Solution(1)<< endl;
cout << endl;
return 0;
}