Question
I want to convert C++ code to C#. C++ Code: #include #include #include using namespace std; int main() { int
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;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here is the C equivalent of the provided C code csharp using System using SystemCollectionsG...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started