#include <stdio.h>
#define FAIL -1
#define OK 0
#define TRUE 1
#define FALSE 0

int parentesizzata(char *s);

int main(int argc, char **argv){
	if(argc<2) return FAIL;
	if (parentesizzata(argv[1]))
		printf("La stringa \"%s\" e' ben parentesizzata\n", argv[1]);
	else
		printf("La stringa \"%s\" non e' ben parentesizzata\n", argv[1]);
	return OK;
}


int parentesizzata(char *s){
	int count=0, i;
	for(i=0; s[i]!='\0'; i++)
		switch(s[i]){
            case '[':
            case '(': count++; 
				break;
            case ']':
			case ')': count--;
				if (count<0) return FALSE;
				break;
		}
		
	if (count==0) return TRUE;
	else return FALSE;
}
