알고리즘/SWEA

[SWEA 1221] GNS

히더 2018. 8. 10. 16:33

출처 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14jJh6ACYCFAYD


#include <iostream>

#include <algorithm>

#include <memory.h>

#include <string>

using namespace std;


int N,result;

char arr[10][4] = { "ZRO","ONE","TWO","THR","FOR","FIV","SIX","SVN","EGT","NIN" };

int cnt[10];


int main()

{

int T; int t = 1; string tt;

cin >> T;

while (T--)

{

cin >> tt; cin >> N;

for (int i = 0; i < N;i++)

{

char tmp[4]; cin >> tmp;

for (int j = 0; j < 10; j++)

if (!strcmp(tmp, arr[j])) {

cnt[j]++;

break;

}

}



cout << "#" << t++ << " ";

for (int j = 0; j < 10; j++) {

while (cnt[j] != 0) {

cout << arr[j] << " ";

cnt[j]--;

}

}


}


return 0;

}