---
title: "轩辕互动面试1题"
author: "jythoner"
date: "2010-04-12T08:40:04Z"
tags: []
categories: ["编程语言"]
slug: "1"
draft: false
lastmod: "2010-04-21T14:01:13Z"
id: 641518
url: "https://jythoner.iteye.com/blog/641518"
---

有一组括号 （（（（（）（）））（）（）（））类似于这样的，写一个算法，判断这样的括号是不是成对的。


```java

private string ReturnStr(string str)
	{
		string myStr = str;
		string[] strTemp = myStr.Split(',');
		do
		{
			strTemp = myStr.Split(',');
			for (int i = 0; i < strTemp.Length; i++)
			{
				if (strTemp[i] != "")
				{
					string starStr = strTemp[i];
					string endStr = i+2  <= strTemp.Length ? strTemp[i + 1] : "";
					if (starStr == "(" && endStr == ")")
					{
						strTemp[i] = "";
						strTemp[i + 1] = "";
					}
				}
			}
			myStr = "";
			for (int i = 0; i < strTemp.Length; i++)
			{
				if (strTemp[i] != "")
				{
					myStr += strTemp[i] + ",";
				}
			}
			myStr.TrimEnd(',');

	} while (myStr.Length>2);
	myStr.TrimEnd(',');
	return myStr;
	}


```