auto

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define bug(a) cout<<"# "<<a<<" ";
#define bug2(a,b) cout<<"# "<<a<<" # "<<b<<endl;
#define bug3(a,b,c)  cout<<"# "<<a<<" # "<<b<<" # "<<c<<endl;

void test1()    //字符串
{
    string s="asdfadsf";
    cin>>s;
    for(auto ch: s)
        bug(ch);
}
void test2()    //数组
{
    int a[]={1,5,8,7,8,9,8};
    for(auto i: a)
       cout<<i<<endl;
}
void test3()    //stl 容器 vector  dequeue
{
    vector<int> v={1,5,6,5,8,5};
    for(auto& it: v)                //在这段程序中,可以返回引用值,通过引用可以修改容器内容   (这个引用我也不知道什么意思,先欠着叭)
        bug(it);
    cout<<endl;
    for(auto it=v.begin();it!=v.end();++it)
        bug(*it);


    vector<string> v1={"i","like","liu"};
    for(auto& it: v1){
        //it="c++";
        bug(it);
    }


}
void test4()    //stl map
{
    //遍历map返回的是pair变量,不是迭代器
    map<int,int> mp;
    for(int i=0;i<=10;i++)
    {
        mp[i]=i+10;
    }
    for(auto it: mp)
        cout<<(it.first)<<"->"<<(it.second)<<endl;
}

int main()
{
   //test1();
   test2();
  //test3();
    //test4();
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值