当前位置:网站首页>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;
}
如图为程序运行结果:

输出完成
边栏推荐
- Getting Started with JNI
- C语言-内存操作函数
- Jetpack之dataBinding
- 2021-09-11 C language variables and memory allocation
- Interpretation of the paper: GAN and detection network multi-task/SOD-MTGAN: Small Object Detection via Multi-Task Generative Adversarial Network
- The Summer of Open Source 2022 is coming | Welcome to sign up for the OpenMLDB community project~
- 127.0.0.1 connection refused
- Visual studio2019 配置使用pthread
- 欧拉法解微分方程
- Dark Horse Event Project
猜你喜欢

USB in NRZI to encode the data

The third phase of the contributor task is wonderful

OpenMLDB Pulsar Connector:高效打通实时数据到特征工程

第四范式OpenMLDB优化创新论文被国际数据库顶会VLDB录用

Jetpack之dataBinding

USB URB
![swagger错误:WARN i.s.m.p.AbstractSerializableParameter - [getExample,421] - Illegal DefaultValue null](/img/46/6ceeb330821d28b44742436da4123c.png)
swagger错误:WARN i.s.m.p.AbstractSerializableParameter - [getExample,421] - Illegal DefaultValue null

Manufacturer Push Platform-Huawei Access

Open Source Machine Learning Database OpenMLDB Contributor Program Fully Launched

OpenMLDB v0.5.0 released | Performance, cost, flexibility reach new heights
随机推荐
Dark Horse Event Project
jdbc接口文档参考,jdbc接口方法逻辑探究
实时特征计算平台架构方法论和基于 OpenMLDB 的实践
SearchGuard configuration
JS advanced web page special effects (pink teacher notes)
JS case exercise (classic case of teacher pink)
Day 84
IIC and SPI
ARM assembly instruction ADR and LDR
buuctf hacknote
Tinker's self-introduction
The whole process of Tinker access --- Compilation
Jetpack之dataBinding
Day 81
【无标题】
Compilation exception resolution
Day 86
swagger错误:WARN i.s.m.p.AbstractSerializableParameter - [getExample,421] - Illegal DefaultValue null
第四范式OpenMLDB优化创新论文被国际数据库顶会VLDB录用
2021-09-11 C language variables and memory allocation