c++中count的用法,count<
使用方法是count(begin,end,‘a’),其中begin指的是起始地址,end指的是结束地址,第三个参数指的是需要查找的字符
count函数可以用来统计字符串中某个字符的个数
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s= "abcdefgaabbccd";
int num =count(s.begin(),s.end(),'a');
cout<<num<<endl;
}
写错了吧,应该是cout,不是count
cout使用方法:
#include <iostream>
using namespace std;
int a = 10;
float b = 11.2;
cout << "测试" << a << "," << b <<endl;
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632