当前位置:网站首页>过滤字符串只保留串中的字母字符 (10 分)请编写一个函数fun,函数的功能是:输入一个字符串,过滤此串,只保留串中的字母字符,并统计新生成串中包含的字母个数。
过滤字符串只保留串中的字母字符 (10 分)请编写一个函数fun,函数的功能是:输入一个字符串,过滤此串,只保留串中的字母字符,并统计新生成串中包含的字母个数。
2022-04-21 13:40:00 【Tomatos_baby】
请编写一个函数fun,函数的功能是:输入一个字符串,过滤此串,只保留串中的字母字符,并统计新生成串中包含的字母个数。
函数接口定义:
int fun(char *ptr);
其中 ptr 是用户传入的参数。函数的功能是:输入一个字符串,过滤此串,只保留串中的字母字符,并统计新生成串中包含的字母个数返回。
裁判测试程序样例:
#include <stdio.h>
int fun(char *ptr);
int main()
{
char str[80];
int s;
gets(str);
s=fun(str);
printf("The new string is :");puts(str);
printf("There are %d char in the new string.",s);
return 0;
}
/* 请在这里填写答案 */
输入样例:
hjds34jj
输出样例:
The new string is :hjdsjj
#include<string.h>
int fun(char* ptr)
{
int number = 0;
int n = 0, i;
for (i = 0; ptr[i]; i++)
if (ptr[i] >= 'a' && ptr[i] <= 'z')
ptr[n++] = ptr[i];
ptr[n] = '\0';
return strlen (ptr);
}
版权声明
本文为[Tomatos_baby]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Tomatos_baby/article/details/124318143
边栏推荐
- Baidu map development custom information window openinfowindow style
- After the completion of hundreds of millions of yuan of financing, smart bank plans to land urban intelligent driving products in more than 100 cities
- Leetcode: countless denominations of coins get the option of amount (DP)
- What about first-class insurance? Is there a charge? What are the waiting requirements?
- 前馈神经网络
- 一份很棒的外设驱动库!(基于STM32F4)
- Hcip road OSPF expansion configuration
- no server suitable for synchronization found
- Do self media and short videos, and don't trust those mutual relations and mutual praise
- Can great talents be of little use? Oceanbase integration scenario test
猜你喜欢

一份很棒的外设驱动库!(基于STM32F4)

What kind of comfortable sports earphones are recommended

International logistics centralized transportation system source code, overseas warehousing cross-border transshipment system source code

u盘数据丢失了怎么恢复?u盘数据恢复,2个方案完成

Exercise questions and answers of quality, investment and progress control in 2022 supervision engineer examination

flink-1.12.0版Yarn安装部署

【csnote】db异常(冗余数据、修改异常、删除异常、插入异常)

How to install the database of Dameng 8 version in Kirin V10 SP2

Feedforward neural network

Technology giants compete to enter, who can become the "number one player" of the meta universe?
随机推荐
建议:ALT+X 标注已标注的区域,是否可以取消标注呢?
thread库和 asio 库区别
一文读懂Faster RCNN
Réaliser l'affichage aléatoire de l'étiquette, de la taille de la police et de la couleur
In office word 2016, omml2mml appears when the formula edited by word's own formula editor is transferred to MathType Solutions to XSL problems
Open mmlab / mmpose installation and use tutorial
Peking University ACM problems 1012: Maya calendar
npm---package.json
Leetcode: countless denominations of coins get the option of amount (DP)
STM32 drives st7789v2 TFT screen
农产品期货品种有哪些呢?
Longest common subsequence (I) (dynamic gauge)
2021-2022 Guangdong Vocational College Students' professional skills competition
Markdown语法及测试
SECOND: Sparsely Embedded Convolutional Detection
Go language file operation
Could not load dynamic library ‘libcusolver.so.11‘
2022 supervision engineer contract management exercises and answers
被迫选择了到了外包公司
[digital signal processing] linear constant coefficient difference equation (use matlab to solve the example of "linear constant coefficient difference equation" | a vector analysis | B vector analysi