国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

PAT A1049. Counting Ones (30)

2019-11-08 02:01:31
字體:
來源:轉載
供稿:網友

The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's in 1, 10, 11, and 12.

Input Specification:

Each input file contains one test case which gives the positive N (<=230).

Output Specification:

For each test case, PRint the number of 1's in one line.

Sample Input:
12Sample Output:
5
#include <cstdio>#include <algorithm>#include <cstring>#include <string>#define Max 100010using namespace std;int main(){	int n,k=1;	int m=0;	int p,q,r,l;	scanf("%d",&n);	for(int i=1;i<=n;i++)	{		p=i;		while(p!=0)		{			q=p%10;			if(q==1) m++;			p=p/10;		}	}		printf("%d/n",m);	system("pause");	return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大石桥市| 芜湖县| 无棣县| 兴安县| 吉水县| 宜州市| 政和县| 筠连县| 遂平县| 志丹县| 罗平县| 大理市| 达日县| 丰宁| 隆德县| 息烽县| 突泉县| 扎鲁特旗| 凤台县| 清水河县| 阿图什市| 天镇县| 三亚市| 吉隆县| 迁安市| 宜丰县| 三门县| 漳平市| 普陀区| 鄢陵县| 桐柏县| 绍兴县| 黎城县| 平阳县| 河曲县| 永登县| 墨脱县| 麻栗坡县| 吴旗县| 汉源县| 高要市|