UVA Solution 468 – Key to Success – Solution in C, C++

UVA Onilne Judge Solution UVA-Volume 4

UVA Solution 468 – Key to Success – Solution in C, C++ – Volume 4

UVA Online Judge Solution 468 | Volume 4
UVA Problem Link – 468 – Key to Success solution

Problem Name: 468 – Key to Success solution
Problem Number : UVA – 468 solution
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C/C plus plus

UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list

UVA Solution 468 – Key to Success Code in C/CPP:

#include <stdio.h>
#include <stdlib.h>

struct
node {
int
v, c;
node() {
v = 0;
c = 0;
}
};

int
cmp(const void *i, const void *j) {
node *a, *b;
a = (node *)i, b = (node *)j;
return
b->v - a->v;
}

int
main() {
int
t, i;
char
str[10], a[10000], b[10000];
scanf("%d", &t);
gets(str);
while
(t--) {
gets(str);
gets(a);
gets(b);
node aI[128], bI[128];
for
(i = 0; i < 128; i++)
aI[i].c = bI[i].c = i;
for
(i = 0; a[i]; i++)
aI[a[i]].v++;
for
(i = 0; b[i]; i++)
bI[b[i]].v++;
qsort(aI, 128, sizeof(node), cmp);
qsort(bI, 128, sizeof(node), cmp);
int
mapp[128] = {};
for
(i = 0; i < 128; i++) {
mapp[bI[i].c] = aI[i].c;
}

for
(i = 0; b[i]; i++)
putchar(mapp[b[i]]);
puts("");
if
(t)
puts("");
}

return
0;
}

Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list, UVA 468 – Key to Success   code in C, UVA 468 code in C++, UVA 468 – Key to Success solution in C, UVA Key to success solution

Leave a Reply

Your email address will not be published.