Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

有史以来写过的嵌套最多层的循环。。10个for。。

Posted by reve at 2005-09-27 20:24:37
void FindAllSum()
{
	int a, b, c, d, e, f, g, h, i, j;
	int S[10];

	for (a = 0; a < 2; ++a)
	{
		if (a == 0)
			S[0] = 0;
		else
			S[0] = F[0];
		for (b = 0; b < 2; ++b)
		{
			if (b == 0)
				S[1] = S[0];
			else
				S[1] = S[0] + F[1];
			for (c = 0; c < 2; ++c)
			{
				if (c == 0)
					S[2] = S[1];
				else
					S[2] = S[1] + F[2];
				for (d = 0; d < 2; ++d)
				{
					if (d == 0)
						S[3] = S[2];
					else
						S[3] = S[2] + F[3];
					for (e = 0; e < 2; ++e)
					{
						if (e == 0)
							S[4] = S[3];
						else
							S[4] = S[3] + F[4];
						for (f = 0; f < 2; ++f)
						{
							if (f == 0)
								S[5] = S[4];
							else
								S[5] = S[4] + F[5];
							for (g = 0; g < 2; ++g)
							{
								if (g == 0)
									S[6] = S[5];
								else
									S[6] = S[5] + F[6];
								for (h = 0; h < 2; ++h)
								{
									if (h == 0)
										S[7] = S[6];
									else
										S[7] = S[6] + F[7];
									for (i = 0; i < 2; ++i)
									{
										if (i == 0)
											S[8] = S[7];
										else
											S[8] = S[7] + F[8];
										for (j = 0; j < 2; ++j)
										{
											if (S[8] == 12)
											{
												int aa;
												aa = 100;
											}

											if (j == 0)
												flag[ S[8] ] = true;
											else
												flag[ S[8] + F[9] ] = true;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	flag[0] = false;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator