| Task: | Lehmät |
| Sender: | Verlet |
| Submission time: | 2022-11-10 10:59:24 +0200 |
| Language: | C++ (C++17) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
8 | cin >> width >> height;
| ^~~
| std::cin
In file included from input/code.cpp:1:
/usr/include/c++/11/iostream:60:18: note: 'std::cin' declared here
60 | extern istream cin; /// Linked to standard input
| ^~~
input/code.cpp:10:8: error: structured binding declaration cannot have type 'int'
10 | int[] map = new int[width * height];
| ^~
input/code.cpp:10:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
input/code.cpp:10:8: error: empty structured binding declaration
input/code.cpp:10:11: error: expected initializer before 'map'
10 | int[] map = new int[width * height];
| ^~~
input/code.cpp:16:19: warning: comparison with string literal results in unspecified behavior [-Waddress]
16 | if (c == "*") {...Code
#include <iostream>
int main() {
int width, height, upperleftx, upperlefty, downrightx, downrighty;
bool firt = true;
cin >> width >> height;
int[] map = new int[width * height];
for (int y = 0; y < width; y++) {
for (int x = 0; x < height; x++) {
char c;
cin >> c;
if (c == "*") {
if (first) {
first = false;
upperleftx = x, upperlefty = y;
}
downrightx = x, downrighty y;
}
if (c == "@") {
map[y * width + x] = 1;
}
}
}
int beginning = (upperlefty+1)*width+upperleftx+1;
int end = (downrighty-1)*width+downrightx-1;
int n = 0;
for (int i = beginning; i < end; i++) {
if (map[i] = 1) {
n++;
}
}
cout << n;
}