#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); }
#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); }
上一篇 阳阳买苹果
下一篇 字符型变量的使用
版权所有 (c)2021-2022 MSHXW.COM
ICP备案号:晋ICP备2021003244-6号