5 条题解

  • 0
    @ 2025-3-5 11:26:49
    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main() {
        int n;
        cin >> n;
        vector<int> vec;
    
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            vec.push_back(a);
        }
    
        int x, y;
        cin >> x;
        cin >> y;
        vec.insert(vec.begin() + x - 1, y);
    
        for (const auto& elem : vec) {
            cout << elem << "\n";
        }
        cout << endl;
    
        return 0;
    }
    
    • 0
      @ 2025-2-27 14:35:14
      #include <bits/stdc++.h>
      using namespace std;
      typedef long long ll;
      
      int main(){
          vector<int> a;
          int n, t, pos;
          cin >> n;
          for (int i = 0; i < n; i++) {
              cin >> t;
              a.push_back(t);
          }
      
          cin >> pos;
          cin >> t;
          a.insert(a.begin() + pos - 1, t);
          for (int i = 0; i < a.size(); i++) {
              cout << a[i] << endl;
          }
      
          return 0;
      }
      
      • 0
        @ 2025-2-3 1:35:28
        #include <bits/stdc++.h>
        using namespace std;
        
        int main()
        {
            int n, m, x, y;
            cin >> n;
            vector<int> arr;
            for (int i = 0; i < n; i++)
            {
                cin >> m;
                arr.push_back(m);
            }
            cin >> x >> y;
            arr.insert(arr.begin() + x - 1, y);
            for (auto & ele : arr)
            {
                cout << ele << '\n';
            }
            return 0;
        }
        
        • 0
          @ 2025-1-14 14:03:59
          #include<iostream>
          #include<vector>
          using namespace std;
          int main()
          {
          int n,a,b,c;
          cin>>n;
          vector<int> arr;
          for(int i=0;i<n;i++)
          {
          cin>>a;
          arr.push_back(a);
          }
          cin>>b>>c;
          arr.insert(arr.begin()+b-1,c);
          for(const auto&it:arr)
          {
          cout<<it<<'\n';
          }
          return 0;
          }
          
          • 0
            @ 2024-4-10 18:16:52

            #include <iostream> #include <vector> using namespace std;

            int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

            vector<int> arr;
            int n, num, pos, val;
            cin >> n;
            for (int i = 0; i < n; i++)
            {
                cin >> num;
                arr.push_back(num);
            }
            cin >> pos;
            cin >> val;
            
            arr.insert(arr.begin() + pos - 1, val);
            vector<int> ::iterator it;
            for (it = arr.begin(); it != arr.end(); it++)
            {
                cout << *it << endl;
            }
            return 0;
            

            }

            • 1

            信息

            ID
            71
            时间
            1000ms
            内存
            256MiB
            难度
            4
            标签
            递交数
            369
            已通过
            181
            上传者