btw this is a part of a battleship code
i want to know what the integers a,b,c,d,e,f... do
I know this has something to do with placing ships randomly but it is a little complexed for me. I'd appreciate it if someone took their time to explain it

int placeship( int x, int z[ ][ 10 ] )
{
	int a, b, c, d, e, f, g, h, i, j, k;
	int pc;
	int usum, dsum, lsum, rsum;

	usum = 0;
	dsum = 0;
	lsum = 0;
	rsum = 0;

	pc = 0;

	a = rand() % 10;
	b = rand() % 10;
	c = rand() % 2;

	f = a + x;
	g = b + x;

	e = (x - 1);

		for( d = 0; d <= e; d++)
			{
				i = a - d;

				if( z[ i ][ b ] == 1 )
				{
					usum++;
				}
			}

		for( d = 0; d <= e; d++)
			{
				j = a + d;

				if( z[ j ][ b ] == 1 )
				{
					dsum++;
				}
			}

		for( d = 0; d <= e; d++)
			{
				k = b - d;

				if( z[ a ][ k ] == 1 )
				{
					lsum++;
				}
			}

		for( d = 0; d <= e; d++)
			{
				h = b + d;

				if( z[ a ][ h ] == 1 )
				{
					rsum++;
				}
			}

	if( c != 1 ) // vector: U/D
	{
		if( f >= 10 )
		{

			if( usum == 0 )
			{
					for( d = 0; d <= e; d++) // vector: up ^
					{
						i = a - d;
						z[ i ][ b ] = 1;


					}
					pc = 1;
			}

		}

		if( f < 10 )
		{
			if( dsum == 0)
			{
					for( d = 0; d <= e; d++) // vector: down v
					{
						j = a + d;
						z[ j ][ b ] = 1;


					}

					pc = 1;
			}
		}
	}

	if( c == 1 ) // vector: L/R
	{
		if( g >= 10 )
		{
			if( lsum == 0 )
			{
					for( d = 0; d <= e; d++) // vector: left <-
					{
						k = b - d;
						z[ a ][ k ] = 1;


					}

					pc = 1;
			}
		}

		if( g < 10 )
		{
			if( rsum == 0 )
			{

					for( d = 0; d <= e; d++) // vector: right ->
					{
						h = b + d;
						z[ a ][ h ] = 1;


					}

					pc = 1;
			}
		}
	}

	return pc;

Have to work too hard trying to follow the code with that awful indentation. See this, reformat and try again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.