当前位置:网站首页>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);
}
边栏推荐
- 核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)
- selenium 浏览器(1)
- Redis: redis data structure and key operation commands
- Using registered classes to realize specific type matching function template
- 金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
- [understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
- Canvas utility library fabric JS user manual
- QT learning 24 layout manager (III)
- 金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
- simpleParallax. JS (create poor visual effects for website pictures)
猜你喜欢
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线

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

QT learning 24 layout manager (III)

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

JVM系列——概述,程序计数器day1-1

JS Part 2

如何使用lxml判断网站公告是否更新
[email protected])"/>金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])

Go: send the get request and parse the return JSON (go1.16.4)

QT learning 20 standard dialog box in QT (middle)
随机推荐
Dynamic programming 01 knapsack and complete knapsack
如何使用lxml判断网站公告是否更新
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
GoLand 2021.2 configure go (go1.17.6)
Function calling convention
How to delete an attribute or method of an object
Dlopen() implements dynamic loading of third-party libraries
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Qt学习21 Qt 中的标准对话框(下)
RocksDB LRUCache
Qt学习22 布局管理器(一)
jvm-对象生命周期
消息订阅与发布
Duet date picker (time plug-in that can manually enter the date)
Interface for querying IP home
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
1px problem of mobile terminal
Similarities and differences of sessionstorage, localstorage and cookies
How to promote the progress of project collaboration | community essay solicitation