Here is my code for problem 488:

Code: Select all

```
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n_cases, *amp, *freq, i, j, k, l;
scanf("%d", &n_cases);
printf("\n");
amp = (int *) calloc(n_cases, sizeof(int));
freq = (int *) calloc(n_cases, sizeof(int));
for (i = 0; i < n_cases; i++)
{
scanf("%d%d", &[i], &freq[i]);
printf("\n");
}
for (i = 0; i < n_cases; i++)
{
for (j = 0; j < freq[i]; j++)
{
for (k = 1; k <= amp[i]; k++)
{
for (l = 0; l < k; l++)
printf("%d", k);
printf("\n");
}
for (k = amp[i] - 1; k >= 1; k--)
{
for (l = 0; l < k; l++)
printf("%d", k);
printf("\n");
}
if ((j < freq[i] - 1) || (i < n_cases - 1))
printf("\n");
}
}
free(amp);
free(freq);
return 0;
}
```