37 lines
745 B
C++
37 lines
745 B
C++
#include <iostream>
|
|
#include <stdlib.h>
|
|
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
string input;
|
|
const string forward = "forward";
|
|
const string up = "up";
|
|
const string down = "down";
|
|
int horizontal = 0;
|
|
int depth = 0;
|
|
|
|
while(getline(cin,input))
|
|
{
|
|
int amount = atoi(&input.c_str()[input.find(' ')]);;
|
|
|
|
if (string::npos != input.find(forward))
|
|
{
|
|
horizontal += amount;
|
|
}
|
|
else if (string::npos != input.find(up))
|
|
{
|
|
depth -= amount;
|
|
}
|
|
else if (string::npos != input.find(down))
|
|
{
|
|
depth += amount;
|
|
}
|
|
}
|
|
|
|
cout << horizontal*depth << endl;
|
|
|
|
return 0;
|
|
}
|