C++容器字符串数组下标迭代访问
#include<iostream>#include<vector>
#include<string>
using namespace std;
int main(void){
//---------------------摰孵膥
vector<int>v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
//銝????��挪�䔮摰孵膥��蝝惩�閧鍂
for(size_t i=0;i<v.size();i++){
cout<<v<<endl;
}
//餈凋誨for敺芰㴓
for(auto i:v){
cout<<i<<endl;
}
//---------------------------------摮㛖泵銝猖tring
string str="my name is gaowanlu";
for(size_t i=0;i<str.size();i++){
cout<<str;
}
cout<<endl;
//餈凋誨for敺芰㴓
for(auto i:str){
cout<<i;
}
cout<<endl;
//----------------------------------�㺭蝏�
double lf={
12.12,13.13,14.14
};
//銝????��挪�䔮
for(size_t i=0;i<3;i++){
cout<<lf<<endl;
}
//餈凋誨for敺芰㴓
for(auto i:lf){
cout<<i<<endl;
}
return 0;
}
文档来源:51CTO技术博客https://blog.51cto.com/u_15302296/3072262
页:
[1]