UVA 1593	Alignment of Code

#include <bits/stdc++.h>
#define endl "\n"
#define LL long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fk freopen("input.txt", "r", stdin)
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
using namespace std;
typedef pair <int,int> PII;

int maxn[1005];
int cnt;
vector <string> now;
vector <vector <string> > total;


int main(){
    string s, words;
   
   IOS;

    memset(maxn, 0, sizeof(maxn));
    while(getline(cin, s)){
        stringstream ss(s);
        cnt = 0;
        now.clear();
        while(ss >> words){
            maxn[cnt] = max(maxn[cnt], (int)words.size());
            cnt++;
            now.push_back(words);
        }
        total.push_back(now);
      
    }
    for(int r = 0; r < total.size(); r++){
        for(int c = 0; c < total[r].size(); c++){
         
            cout << total[r][c];
           for(int i = 0; i < maxn[c] - total[r][c].length() + 1; i++)
              if(c < total[r].size() - 1)
                 cout << " ";
        }
        cout << endl;
    }
  return 0;
}

相关文章:

  • 2021-04-30
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-12-19
  • 2021-05-18
  • 2021-09-03
  • 2021-12-08
猜你喜欢
  • 2022-02-10
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案