/
uri1278.cpp
34 lines (32 loc) · 974 Bytes
/
uri1278.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define MAX 212
int main(void){
int N, maior, i, first = 1;
char str[MAX][MAX], tmp[MAX];
while(scanf("%d ", &N), N){
if(first) first = 0;
else printf("\n");
for(maior = i = 0; i < N; i++){
fgets(tmp, MAX, stdin);
int espaco = -1, j, k = 0;
for(j = 0; tmp[j] != '\n'; j++){
if(tmp[j] != ' ' && espaco == 1){
str[i][k] = ' '; k++;
str[i][k] = tmp[j]; k++;
espaco = 0;
} else if(tmp[j] != ' ') {
str[i][k] = tmp[j]; k++;
espaco = 0;
} else if(espaco != -1) espaco = 1;
}
str[i][k] = '\0';
maior = max(maior, (int)strlen(str[i]));
}
for(i = 0; i < N; i++)
printf("%*s\n", maior, str[i]);
}
return 0;
}