#include int main(void) { typedef struct { char kakko; int num; } Kakko; char input[] = "(())"; int len = 4; int n = 4; int i = 0; int answer; n = n - 1; Kakko array[len]; for (int i = 0; i < len; i++) { array[i].kakko = input[i]; array[i].num = i; } while (len != 0) { if ( array[i].kakko == ')') { if (array[i - 1].num == n) { answer = array[i].num; } else if (array[i].num == n) { answer = array[i - 1].num; } for (i; i < len - 1; i++) { array[i - 1] = array[i + 1]; } len -= 2; i = 0; } i++; } answer += 1; printf("%d", answer); }