当前位置:网站首页>Exercise 6-1 classify and count the number of characters
Exercise 6-1 classify and count the number of characters
2022-07-03 14:09:00 【ᯤ⁹ᴳ⁺ ·】
exercises 6-1 Classify and count the number of characters (15 branch )
This question requests to realize a function , Statistics of Chinese and English letters in a given string 、 Space or enter 、 The number of numeric characters and other characters .
Function interface definition :
void StringCount( char s[] );
among char s[] Is the string passed in by the user . function StringCount Must be in one line according to
letter = The number of English letters , blank = The number of spaces or carriage returns , digit = Number of characters , other = The number of other characters
Format output .
Sample referee test procedure :
#include <stdio.h>
#define MAXS 15
void StringCount( char s[] );
void ReadString( char s[] ); /* By the referee , Omit no watch */
int main()
{
char s[MAXS];
ReadString(s);
StringCount(s);
return 0;
}
/* Your function will be put here */
sample input :
aZ &
09 Az
sample output :
letter = 4, blank = 3, digit = 2, other = 1void StringCount(char s[]){
int letter=0,blank=0,digit=0,other=0,i=0;
do{
if(s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z'){
letter++;
}else if(s[i]==' '||s[i]=='\n'){
blank++;
}else if (s[i] >= '0' && s[i] <= '9'){
digit++;
}else{
other++;
}
i++;
}while(s[i]!='\0');
printf("letter = %d, blank = %d, digit = %d, other = %d", letter, blank, digit, other);
}
边栏推荐
- GoLand 2021.2 configure go (go1.17.6)
- Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
- Redis: redis data structure and key operation commands
- Programmable logic device software testing
- 28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
- Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
- Common network state detection and analysis tools
- Using registered classes to realize specific type matching function template
- JS matrix zero
- [understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
猜你喜欢

Qt学习20 Qt 中的标准对话框(中)

TS code automatically generates JS

“又土又穷”的草根高校,凭什么被称为“东北小清华”?

Interface for querying IP home

Redis:字符串類型數據的操作命令

The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
[email "/>Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email

JVM object lifecycle
[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)"/>MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)

Go: send the get request and parse the return JSON (go1.16.4)
随机推荐
How to promote the progress of project collaboration | community essay solicitation
Use vscode to view hex or UTF-8 codes
Summary of common error reporting problems and positioning methods of thrift
解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
JS continues to explore...
FPGA test method takes mentor tool as an example
Onmenusharetimeline custom shared content is invalid, and the title and icon are not displayed
Dynamic programming 01 knapsack and complete knapsack
Spring cup eight school league
How to delete an attribute or method of an object
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
可编程逻辑器件软件测试
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
JS Part 2
RocksDB LRUCache
Windos creates Cordova prompt because running scripts is prohibited on this system
Common mixins
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
GoLand 2021.1: rename the go project
Interface for querying IP home