PAT-统计个位数字(基础函数题)
来源:互联网 发布:久坐肚子大 知乎 编辑:程序博客网 时间:2024/06/02 03:24
本题要求实现一个函数,可统计任一整数中某个位数出现的次数。例如-21252中,2出现了3次,则该函数应该返回3。
函数接口定义:
int Count_Digit ( const int N, const int D );
其中N
和D
都是用户传入的参数。N
的值不超过int
的范围;D
是[0, 9]区间内的个位数。函数须返回N
中D
出现的次数。
裁判测试程序样例:
#include <stdio.h>int Count_Digit ( const int N, const int D );int main(){ int N, D; scanf("%d %d", &N, &D); printf("%d\n", Count_Digit(N, D)); return 0;}/* 你的代码将被嵌在这里 */
输入样例:
-21252 2
输出样例:
3
程序代码int Count_Digit(const int N, const int D){int count,temp,x;x=N;if(x<0)x=-x;do{temp=x%10;if(temp==D)count++;x=x/10;}while(x>0);return count;}
2 0
- PAT-统计个位数字(基础函数题)
- PAT基础题 4-9 统计个位数字
- PAT练习基础编程题目之统计个位数字
- PAT基础编程习题集 4-9 统计个位数字
- PTA测试基础题--统计个位数字
- (函数题)4-9 统计个位数字
- 统计个位数字
- 统计个位数字
- 统计个位数字
- 统计个位数字
- 4-9 统计个位数字
- 4-9 统计个位数字
- 4-9 统计个位数字 (15分)
- 4-9 统计个位数字 (15分)
- 4-9 统计个位数字 (15分)
- 4-9 统计个位数字 (15分)
- 4-9 统计个位数字 (15分)
- 4-9 统计个位数字 (15分)
- 2-5-归并链式存储的单链表-线性表-第2章-《数据结构》课本源码-严蔚敏吴伟民版
- Linux下怎么输入重音符号
- UICollectionViewCell
- android service 详解
- UFLDL教程答案(7):Exercise:Learning color features with Sparse Autoencoders
- PAT-统计个位数字(基础函数题)
- Shell
- poj 2253 Frogger【最短路】
- 基于用户的协同过滤算法(Java实现或R语言实现
- Android学习之多线程编程(handler篇)
- AddForce和velocity有什么区别
- GDAL编译
- PAT-判断奇偶性(基础函数题)
- C# 关闭当前窗体打开另一窗体?