I want to convert C++ code to C#. C++ Code: #include #include #include using
Question:
I want to convert C++ code to C#.
C++ Code:
#include
#include
#include
using namespace std;
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; i++)
{
int w, h, n;
cin >> w >> h >> n;
vector
vector
for (int j = 0; j < h; j++)
{
cin >> map1[j];
}
for (int j = 0; j < h; j++)
{
cin >> map2[j];
}
vector
for (int j = 0; j < n; j++)
{
int x, y;
cin >> x >> y;
shots.push_back({x, y});
}
int score1 = 0;
int score2 = 0;
int player = 1;
for (auto& shot : shots)
{
int x = shot.first;
int y = shot.second;
if (player == 1)
{
if (map2[y][x] == '#')
{
score1++;
player = 2;
}
else
{
player = 2;
}
}
else
{
if (map1[y][x] == '#')
{
score2++;
player = 1;
}
else
{
player = 1;
}
}
}
cout << "Player " << (score1 > score2 ? 1 : 2) << " won." << endl;
}
return 0;
}
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell