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

输出完成
边栏推荐
- 使用c语言实现井字棋(有源码,可以直接运行)
- Day 70
- jdbc接口文档参考,jdbc接口方法逻辑探究
- Day 84
- Day 73
- The mount command - mounted read-only, solution
- Day 78
- Interpretation of the paper: GAN and detection network multi-task/SOD-MTGAN: Small Object Detection via Multi-Task Generative Adversarial Network
- Day 72
- 解决npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead.
猜你喜欢

Vscode remote connection server terminal zsh+Oh-my-zsh + Powerlevel10 + Autosuggestions + Autojump + Syntax-highlighting

127.0.0.1 已拒绝连接

轻松理解进程与线程

OpenMLDB Pulsar Connector: Efficiently connect real-time data to feature engineering

本地缓存cookie的使用

Interpretation of the paper: GAN and detection network multi-task/SOD-MTGAN: Small Object Detection via Multi-Task Generative Adversarial Network

解决npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead.

Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain

jdbc接口文档参考,jdbc接口方法逻辑探究

The whole process of Tinker access --- configuration
随机推荐
函数使用记录
Day 67
three.js基础学习
OpenMLDB v0.5.0 发布 | 性能、成本、灵活性再攀高峰
Regular expression replacement for batch quick modification code
Day 73
C语言实现扫雷游戏
Use c language to implement tic-tac-toe chess (with source code, you can run it directly)
Js method commonly used objects and attributes
C语言预处理
Scene-driven feature calculation method OpenMLDB, efficient implementation of "calculate first use"
js 学习进阶(Dom部分 pink老师教学笔记)
开源机器学习数据库OpenMLDB贡献者计划全面启动
Manufacturer Push Platform-Huawei Access
[Meetup] OpenMLDBxDolphinScheduler engineering and scheduling link link characteristics, building the end-to-end MLOps workflow
The whole process of Tinker access --- Compilation
2021年vscode终端设置为bash模式
heap2 (tcache attack,house of orange)
开发公众号授权遇到的redirect_uri参数错误
自己动手写RISC-V的C编译器-01实现加减法