当前位置:网站首页>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);
}
边栏推荐
猜你喜欢

allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取

JVM family - overview, program counter day1-1

MySQL 数据增删改查综合案例

交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳

Article content typesetting and code highlighting

QT learning 22 layout manager (I)

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

JS matrix zero

玖逸云黑免费无加密版本源码

Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
随机推荐
使用vscode查看Hex或UTF-8编码
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
selenium 浏览器(1)
Implementation of Muduo accept connection, disconnection and sending data
Use and design of Muduo buffer class
Windos creates Cordova prompt because running scripts is prohibited on this system
GoLand 2021.1.1: configure the multi line display of the tab of the open file
jvm-类加载
page owner特性浅析
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
How to promote the progress of project collaboration | community essay solicitation
JS new challenges
Reflection -- basic usage
Uniapp tips - scrolling components
Example analysis of QT learning 18 login dialog box
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
Richview trvstyle liststyle list style (bullet number)
UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
Implementation of Muduo asynchronous logging