#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int t; scanf("%d", &t); for(int i = 0; i < t; i++){ char line[129] = {0}; scanf("%s", line); int stack[129]; int top = 0; int valid = 1; for(int j = 0; j < strlen(line); j++){ char c = line[j]; if(c == '(' || c == '[') stack[top++] = c; else if(c == ')' || c == ']'){ if((c == ')' && stack[top - 1] != '(') || (c == ']' && stack[top - 1] != '[')) valid = 0; else top--; } } if(valid && top == 0) printf("Yes\n"); else printf("No\n"); } return 0; } |
#include <stdio.h> int f91(int n){ int result; if(n <= 100){ result = f91(f91(n + 11)); } else if(n >= 101){ result = n - 10; } return result; } int main(){ int N = 0; while(scanf("%d", &N)){ if(N == 0) break; printf("f91(%d) = %d\n", N, f91(N)); } return 0; } |
10696就是很簡單的function應用。