Przy wpisywaniu przykładowego wejscia rezultat daje 2.
Sprawdzarka daje programowi 0/3. Doradzi ktoś co jest źle?
Tresc zadania:
Przykładowe wejście:
N S S S E E N
Przykładowe wyjście:
2
#include <iostream>
using namespace std;
class dice {
public:
int n = 2;
int s = 5;
int e = 4;
int w = 3;
int bottom = 6;;
int top = 1;
int getResult(int t) {
return t;
}
void rzut(char p) {
int tmp;
if(p == 'S') {
tmp = top;
top = n;
n = bottom;
bottom = s;
s = tmp;
cout << getResult(top) << endl;
}
if(p == 'N') {
tmp = s;
s = bottom;
bottom = n;
n = top;
top = tmp;
cout << getResult(top) << endl;
}
if(p == 'W') {
tmp = s;
top = e;
e = bottom;
bottom = w;
w = tmp;
cout << getResult(top) << endl;
}
if(p == 'E') {
tmp = s;
top = w;
w = bottom;
bottom = e;
e = tmp;
cout << getResult(top) << endl;
}
}
};
int main()
{
dice test;
char input;
while(cin >> input) {
if(input != 'N' && input != 'S' && input != 'E' && input != 'W') {
break;
} else {
test.rzut(input);
}
}
return 0;
}