当前位置:网站首页>Count the number of words C language
Count the number of words C language
2022-07-07 08:57:00 【Please Sit Down】
subject : Enter a line of characters , Statistics of which English words The number of . Space between words .
#define N 50
int main(void){
char str[N];
printf(" Please enter :");
gets(str);
char *p;
p = str;
int sum=0;
while(*p){
if(*p>='a'&&*p<='z' || *p>='A'&&*p<='Z'){
sum++;
}
p++;
}
printf(" Altogether %d Word !",sum);
return 0;
}subject : Enter a line of characters , Statistics of which word The number of . Space between words .
#define N 50
int main(void){
char str[N];
printf(" Please enter :");
gets(str);
char *p;
p = str;
int sum=0,flag=0;
while(*p){
if(*p == ' '){
flag = 0;
}else if(flag == 0){
sum++;
flag = 1;
}
p++;
}
printf(" Altogether %d Word !",sum);
return 0;
}边栏推荐
- Problems encountered in the use of go micro
- Pointer advanced, string function
- Output a spiral matrix C language
- Simulation volume leetcode [general] 1567 Length of the longest subarray whose product is a positive number
- Uniapp wechat applet monitoring network
- 模拟卷Leetcode【普通】1706. 球会落何处
- UnityShader入门精要个人总结--基础篇(一)
- MAC OSX php dyld: Library not loaded: /usr/local/xxxx. dylib
- 平台化,强链补链的一个支点
- Explain Huawei's application market in detail, and gradually reduce 32-bit package applications and strategies in 2022
猜你喜欢
随机推荐
Newly found yii2 excel processing plug-in
Gson converts the entity class to JSON times declare multiple JSON fields named
个人力扣题目分类记录
Esp32-ulp coprocessor low power mode RTC GPIO interrupt wake up
Unity shader beginner's Essentials (I) -- basic lighting notes
指针进阶,字符串函数
ChaosBlade:混沌工程简介(一)
Three series of BOM elements
Interpolation lookup (two methods)
Pointer advanced, string function
Nanjing commercial housing sales enabled electronic contracts, and Junzi sign assisted in the online signing and filing of housing transactions
【踩坑】nacos注册一直连接localhost:8848,no available server
【ChaosBlade:节点 CPU 负载、节点网络延迟、节点网络丢包、节点域名访问异常】
Digital triangle model acwing 1027 Grid access
Personal deduction topic classification record
Mountaineering team (DFS)
Alibaba P8 teaches you how to realize multithreading in automated testing? Hurry up and stop
Lenovo hybrid cloud Lenovo xcloud: 4 major product lines +it service portal
C language for calculating the product of two matrices
Required String parameter ‘XXX‘ is not present









