当前位置:网站首页>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);
}
边栏推荐
- 金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
- How to promote the progress of project collaboration | community essay solicitation
- Selenium browser (1)
- 消息订阅与发布
- MySQL 数据增删改查综合案例
- Installation impression notes
- QT learning 23 layout manager (II)
- QT learning 25 layout manager (4)
- GoLand 2021.2 configure go (go1.17.6)
- Summary of common error reporting problems and positioning methods of thrift
猜你喜欢

全局事件总线

玖逸云黑免费无加密版本源码
[email protected] (FE) | glycyrrhetinic acid modified metal organ"/>Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ

Current situation, analysis and prediction of information and innovation industry

Multi person collaborative data annotation based on Baidu brain easydata from scratch

Interface for querying IP home

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

Installation impression notes

QT learning 21 standard dialog box in QT (Part 2)

FPGA test method takes mentor tool as an example
随机推荐
Record 405 questions about bank callback post request
JS new challenges
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
How to promote the progress of project collaboration | community essay solicitation
虽然不一定最优秀,但一定是最努力的!
Use vscode to view hex or UTF-8 codes
Go: send the get request and parse the return JSON (go1.16.4)
Implementation of Muduo asynchronous logging
1px problem of mobile terminal
JS input number and standard digit number are compared. The problem of adding 0 to 0
Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
Redis: operation command of string type data
Simulated access
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
Qt学习24 布局管理器(三)
Duet date picker (time plug-in that can manually enter the date)
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])