/** * @author Jam Jenkins */ public class GroupCheck { /**Finds the location of unmatched grouping characters. * The grouping characters are: (), {}, <>, []. * * All grouping characters must be used in pairs and cannot * be interlaced. For example, the code *
[html]{a href="works.html"}
* is valid, but *
[html{]a href="works.html"}
* is not valid at position 11 because the ] is * trying to close the { * * Hint: use a stack. * @param code a sequence of characters * @return the position of an error, or -1 if there is * no error */ public int getGroupingError(String code) { return -1; } public static void main(String[] args) { GroupCheck check=new GroupCheck(); String[] code={"
[html]{a href=\"works.html\"}
", "
[html{]a href=\"works.html\"}
"}; int result; for(int i=0; i