当前位置:网站首页>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);
}
边栏推荐
- Windos creates Cordova prompt because running scripts is prohibited on this system
- Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
- QT learning 22 layout manager (I)
- Onmenusharetimeline custom shared content is invalid, and the title and icon are not displayed
- How to delete an attribute or method of an object
- Implementation of Muduo accept connection, disconnection and sending data
- Conversion function and explicit
- JVM family - overview, program counter day1-1
- Multi person collaborative data annotation based on Baidu brain easydata from scratch
- Redis:字符串類型數據的操作命令
猜你喜欢

Qt学习22 布局管理器(一)

RocksDB LRUCache

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

Redis: commandes d'action pour les données de type chaîne

Dlopen() implements dynamic loading of third-party libraries

JVM family - overview, program counter day1-1

JS input number and standard digit number are compared. The problem of adding 0 to 0

jvm-类加载

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

QT learning 19 standard dialog box in QT (top)
随机推荐
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
Common plug-ins for vite project development
Redis: commandes d'action pour les données de type chaîne
JVM垃圾回收机
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
JS download files through URL links
QT learning 25 layout manager (4)
Uniapp tips - set background music
[combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
信创产业现状、分析与预测
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
JS continues to explore...
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
Conversion function and explicit
Go 1.16.4: purpose of go mod tidy
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
[ACNOI2022]猜数
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
Qt学习23 布局管理器(二)
Redis:字符串类型数据的操作命令