-->
当前位置:首页 > 题库 > 正文内容

函数题:过滤字符串只保留串中的数字字符

Luz3年前 (2022-03-30)题库1358
函数的功能是:输入一个字符串,过滤此串,统计串中包含的数字字符个数,正序、逆序输出串中的数字字符。

### 函数接口定义:
c++
int Count_Digit ( char *ptr,int *num );


其中 ptr是用户传入的参数,指向要处理的字符串,返回值是数字字符的个数;参数num是数字字符逆序生成的整数。

### 裁判测试程序样例:
c++

#include <stdio.h>

int Count_Digit ( char *ptr,int *num );

int main()
{
char str[80];
int cnt,num;
gets(str);
cnt=Count_Digit(str,&num);
printf("There are %d digits in the string,they are %s\n",cnt,str);
printf("The number of inversions is %d\n",num);
return 0;
}

/* 请在这里填写答案 */


### 输入样例:

in
hjds34jj,&67


### 输出样例:

out
There are 4 digits in the string,they are 3467
The number of inversions is 7643







答案:若无答案欢迎评论

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。