How to print out the contents of a vector?

后端 未结 19 1174
旧时难觅i
旧时难觅i 2020-11-22 03:46

I want to print out the contents of a vector in C++, here is what I have:

#include 
#include 
#include 
#include         


        
相关标签:
19条回答
  • 2020-11-22 04:37
    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        vector <pair<string,int> > v;
        int n;
        cin>>n;
    int i;
        for( i=0;i<n;i++)
        {
            int  end;
            string str;
            cin>>str;
            cin>>end;
            v.push_back(make_pair(str,end));
        }
    
    
    
    for (int j=0;j<n;j++)
    {
        cout<<v[j].first<< " "<<v[j].second<<endl;
    }``
    }
    
    0 讨论(0)
提交回复
热议问题