혹시몰라서 코드첨부..

munchkin99 Reply 9 years 31 weeks ago
#include <stdio.h> #define MAXLINE 1000 int getline(char line[], int maxline); void copy(char to[], char from[]); main(){ int i,len; int max = 10; char line[MAXLINE]; char result[MAXLINE]; getchar(); fflush(stdin); for(i=0;i<max;i++){ if(getline(line,MAXLINE)==1) result[i] = 'Y'; else result[i] = 'N'; } for(i=0;i<max;i++){ if(i!=max-1) printf("%c\n",result[i]); else printf("%c", result[i]); } return 0; } int getline(char s[],int lim){ char c; int i; int check_check = 0; int check =0; int check_1 = 0; int check_2 = 0; int check_3 = 0; int checka = 0; int checkb = 0; int checkc = 0; for(i=0;i<lim-1 && (c=getchar())!='\n';++i){ if(c=='('){ check_1++; checka = 1; } if(c=='['){ check_2++; checkb = 1; } if(c=='{'){ check_3++; checkc = 1; } if(c==')'){ check_1--; checka = 0; } if(c==']'){ check_2--; checkb = 0; } if(c=='}'){ check_3--; checkc = 0; } if((c=='(')||(c=='[')||(c=='{')) check++; else if((c==')')||(c==']')||(c=='}')) check--; if((check<0)||(check_1<0)||(check_2<0)||(check_3<0)||((checka+checkb+checkc)>1)) check_check = 1; } if((check!=0)||(check_check==1)) return 0; else return 1; }