UVa 10878 ---- 求0.00ms解法


----------------------------------------

//time = 0.012 ms
void Solution0()
{
	//|ooooo.ooo|
	//0123456789
	int arr[10] = { 0, 1<<7, 1<<6, 1<<5, 1<<4, 1<<3, 0, 1<<2, 1<<1, 1 };

	char szLine[32] = {0};
	char c = 0;
	while (gets(szLine) != NULL)
	{
		if(szLine[0] == '_')
			continue;

		for (int i = 1; i < 10; ++i)
		{
			if (szLine[i] == 'o')		
				c += arr[i];
		}
		printf("%c", c);
	}
}

//time = 0.012 ms
void Solution1()
{
	//|ooooo.ooo|
	//0123456789
	int arr[10] = { 0, 1<<7, 1<<6, 1<<5, 1<<4, 1<<3, 0, 1<<2, 1<<1, 1 };

	char szLine[32] = {0};
	char szResult[102400] = {0};
	int nResIndex = 0;
	while (gets(szLine) != NULL)
	{
		if(szLine[0] == '_')
			continue;

		for (int i = 1; i < 10; ++i)
		{
			if (szLine[i] == 'o')		
				szResult[nResIndex] += arr[i];
		}

		++nResIndex;
	}
	printf("%s", szResult);
}





你可能感兴趣的:(UVa 10878 ---- 求0.00ms解法)