UVA 1593(Alignment of Code)
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main()
{
vector < vector<string> > txt;//所有的輸入
string hang,word;//每一行的字母,單個字母
int col=0, row = 0;//row 輸入的行數數
map<int, int> column;//每列的最長單詞長度
//把輸入的文字儲存到txt,對於所有的列,找出該列最長的單詞的長度
while ( getline(cin,hang) )
{
stringstream hangin(hang);
vector <string> temprow;//臨時行
int now=1;//標識讀到當前是改行第幾個單詞(處於第幾列)
while (hangin>>word)
{
temprow.push_back(word);
column[now] = max(column[now], (int)word.size());
now++;
}
txt.push_back(temprow);
}
//輸出答案
for (int i = 0; i < txt.size(); i++)
{
for (int j = 0; j < txt[i].size(); j++)
{
cout << txt[i][j];
for (int k = column[j+1]- txt[i][j].size();k>=0; k--)
{
cout << ' ';
}
cout << ' ';
}
cout << '\n';
}
system("pause");
return 0;
}
執行結果:
相關文章
- mysql_slave :Error_code: 1593解決MySqlError
- solution-uva1594
- [-Flutter趣玩篇-] Align-Alignment 知多少Flutter
- Uva232 Crossword AnswersROS
- Uva 1590 IP Networks
- UVA557 Burger 題解
- UVA11624-Fire!
- 人臉檢測(detection)與人臉校準(alignment)
- Uva 10410 Tree ReconstructionStruct
- UVA - 11178 Morley's TheoremREM
- UVa340 - Master-Mind HintsAST
- Deep CORAL: Correlation Alignment for Deep Domain Adaptation(2016)AIAPT
- 人臉識別技術大總結(1):Face Detection & Alignment
- uva11292-Dragon of LoowaterGo
- uva10935卡片遊戲遊戲
- UVa 1225 - Digit CountingGit
- 計數排序+uva11462排序
- 【MySQL】Last_IO_Errno: 1593 server-uuid重複導致slave報錯MySqlASTServerUI
- UVA 10498 Happiness!(線性規劃)APP
- 並查集+uva10158並查集
- 並查集+uva10608並查集
- UVA 536 二叉樹的遍歷二叉樹
- Digit Counting uva1225Git
- 題解:UVA124 Following Orders
- Uva-1633 Dyslexic Gollum(狀壓DP)Go
- 暴力列舉- uva11464 - Even Parity
- UVA 11235-Frequent values(RMQ)MQ
- 例題6-3 Matrix Chain Multiplication ,Uva 442AI
- (UVA - 10048) Audiophobia(floyd演算法)演算法
- Morley's Therorem(UVA11178+幾何)REM
- UVA 11346 Probability (幾何概型, 積分)
- 遷移學習(COAL)《Generalized Domain Adaptation with Covariate and Label Shift CO-ALignment》遷移學習ZedAIAPT
- [論文閱讀] Aligner@ Achieving Efficient Alignment through Weak-to-Strong Correction
- UVA 11729-Commando War(排序分任務)排序
- 【棧解析表示式】例題6-3 UVa - 442
- (UVA - 10976)Fractions Again?!(技巧,暴力列舉)FractionAI
- UVA - 11396 Claw Decomposition(二分圖染色)
- UVA 11464 Even Parity(部分列舉 遞推)