2022年1月9日第五天

2022年1月9日第五天,第1张

2022年1月9日第五天 初步学习string和map

 

 

#include
#include
#include
using namespace std;
int main()
{
	int i;
	string str = "abcdefg";
	for(i=0;i>str1;
	cout< 
#include
#include
#include
#include
//map¿É½«ÀàËÆÓÚÊý×éϱê±ä³ÉÈÎÒâÖµ£¬Èç01234£¬»òÕßa,'b','c','d'; 
using namespace std;
int main()
{
	mapmp;
	mp['c']=20;
	mp['c']=30;
	mp['m']=20;
	mp['r']=30;
	mp['a']=40;
	printf("%dn",mp['c']);
	mp.erase('c');
	//mp.erase(mp.begin(),mp.end());
	mp.clear();
	for(map::iterator it=mp.begin();it!=mp.end();it++)
	{
		printf("%c %dn",it->first,it->second);
	}
	map::iterator it=mp.find('a');

	printf("%c %dn",it->first,it->second);
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5702531.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存