#include <stdio.h>
#include <string.h>
#define N 100
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
static char cc[N + 1], aa[N + 1][N + 1];
int n, i, x, mn, mx;
scanf("%d%s", &n, cc);
x = mn = mx = 0;
for (i = 0; i < n; i++) {
if (cc[i] == '+')
x++;
else if (cc[i] == '-')
x--;
mn = min(mn, x), mx = max(mx, x);
}
x = 0;
for (i = 0; i < mx - mn; i++)
memset(aa[i], '.', n * sizeof *aa[i]);
for (i = 0; i < n; i++)
if (cc[i] == '+')
aa[mx - ++x][i] = '/';
else if (cc[i] == '-')
aa[mx - x--][i] = '\\';
else
aa[mx - (x + 1)][i] = '_';
for (i = 0; i < mx - mn; i++)
printf("%s\n", aa[i]);
return 0;
}
Compilation message
crtanje.c: In function 'main':
crtanje.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d%s", &n, cc);
| ^~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |