当前位置:网站首页>C语言-6月8日-给定一个字符数组‘i am a student’ 统计字符a的个数并进行输出
C语言-6月8日-给定一个字符数组‘i am a student’ 统计字符a的个数并进行输出
2022-08-11 05:30:00 【曾铎000811】
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char ar[] = {"i am a student"};//定义字符数组
int len = sizeof(ar) / sizeof(ar[0]);//获取字符数组ar的元素个数
int count = 0;
for(int i = 0;i <= len; ++i){//开启循环,当循环至字符数组中的‘a’时,count+1
if(ar[i] == 'a'){
count++;
}
}
printf("该字符串的长度为:%d\n",len);//输出字符数组的长度
printf("该字符串中字符a的个数为:%d\n",count);//输出字符数组中‘a’的个数
return 0;
}
如图为程序运行结果:

输出完成
边栏推荐
- Day 87
- Open Source Machine Learning Database OpenMLDB Contributor Program Fully Launched
- 场景驱动的特征计算方式OpenMLDB,高效实现“现算先用”
- 活动预告 | 4月23日,多场OpenMLDB精彩分享来袭,不负周末好时光
- 8-byte standard request parsing during USB enumeration
- Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain
- USB in NRZI to encode the data
- 实时特征计算平台架构方法论和基于 OpenMLDB 的实践
- OpenMLDB Meetup No.2 会议纪要
- The Summer of Open Source 2022 is coming | Welcome to sign up for the OpenMLDB community project~
猜你喜欢
随机推荐
127.0.0.1 connection refused
第六届蓝帽杯 EscapeShellcode
[Meetup] OpenMLDBxDolphinScheduler engineering and scheduling link link characteristics, building the end-to-end MLOps workflow
ARM assembly instruction ADR and LDR
详解程序执行过程
Day 85
字节(byte)和位(bit)
Real-time Feature Computing Platform Architecture Methodology and Practice Based on OpenMLDB
gerrit configure SSH Key and account, email information
vim 编辑器使用学习
贡献者任务第三期精彩来袭
OpenMLDB Meetup No.2 会议纪要
Day 71
SearchGuard configuration
微信小程序启动页的实现
Compilation exception resolution
【Meetup预告】OpenMLDB+OneFlow:链接特征工程到模型训练,加速机器学习模型开发
基于微信小程序云开发实现的电商项目,可以自行定制开发
[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development
JS进阶网页特效(pink老师笔记)









