VioletaBabel
1159번: 농구 경기 본문
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 | #include<cstdio> #include<cstring> int main() { bool nop = true; int n, count=0; char name[151][31]; scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%s", &name[i]); for(int i = 0; i < n-1; ++i) for(int j = i+1; j<n; ++j) if (strcmp(name[i], name[j]) > 0) { strcpy(name[150], name[i]); strcpy(name[i], name[j]); strcpy(name[j], name[150]); } for (int i = 1; i < n; ++i) { count = (name[i - 1][0] == name[i][0]) ? count + 1 : 0; if (count == 4) { printf("%c", name[i][0]); nop = false; } } if (nop) printf("PREDAJA"); } | cs |
'백준 > 백준-C++' 카테고리의 다른 글
1357번 : 뒤집힌 덧셈 (0) | 2017.09.04 |
---|---|
1292번: 쉽게 푸는 문제 (0) | 2017.09.04 |
1100번: 하얀 칸 (0) | 2017.09.02 |
1037번: 약수 (0) | 2017.09.02 |
1009번: 분산처리 (0) | 2017.09.02 |
Comments