编排字符串

2020-04-03  本文已影响0人  HelloSam
图片.png
图片.png
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    vector<string> vs;
    vector<int> Q;
    int m,i,j;
    cin >> m;
    int counter = 0;
    string str;

    for(i=0;i<m;i++)
    {
        cin >> str;
        counter++;
        vs.push_back(str);
        
        if (counter <= 4 )
        {
            Q.push_back(counter);
        }
        
        
        if(counter==5){
            vs.erase(vs.begin());
            counter--;
        }
        

        for(j=0;j<vs.size();j++)
        {
            cout << Q[j] <<"="<<*(vs.end()-j-1)<<" ";
        }
        
        cout <<endl;
    }
    
    
    return 0;
}
上一篇 下一篇

猜你喜欢

热点阅读