0

hey can anyone convert this c code into c#

#include<stdio.h>        

//Assume following return types while writing the code for this question.     
int output1;       

void GetBuildingCount(int marineCount,int marinePositions[][2])    
{      
int x,y,i,j,temp;
	for(x=0; x<marineCount; x++)
	{
	for( y=0; y<marineCount-1; y++)
	{
	if(marinePositions[y][0]>marinePositions[y+1][0])
			{
 temp = marinePositions[y+1][0];
marinePositions[y+1][0]=marinePositions[y][0];
	marinePositions[y][0] = temp;

			}
			
		if(marinePositions[y][0]>marinePositions[y+1][0])
			{
 temp = marinePositions[y+1][1];
marinePositions[y+1][1]=marinePositions[y][1];
	marinePositions[y][1] = temp;

			}
			

		}

	}
x=0;
y=0;
for(i=0;i<marineCount-1;i++)
{

if(marinePositions[i][0]==marinePositions[i+1][0])
continue;
else 
x++;
}
for(i=0;i<marineCount-1;i++)
{

if(marinePositions[i][1]==marinePositions[i+1][1])
continue;
else 
y++;
}






output1=(x+y)*8-x*y;	
	//Write code here    
}
4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by zmeditation1
0

It will probably work in C# if you take out the function and put it in a C# class.

You REALLY need to look up some proper formatting guidelines, or use an IDE.

0

Allthough you are not using any IO functions here, #include<stdio.h> will not work in C#, use using System; and other using clauses.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.