Test №6 В чем ошибка?
Posted by
Mixail 23 Apr 2016 15:58
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
int shkaf(string name) {
string mas1[9] = { "Alice", "Ariel", "Aurora", "Phil", "Peter", "Olaf", "Phoebus", "Ralph", "Robin" };
string mas2[9] = {"Bambi", "Belle", "Bolt","Mulan", "Mowgle", "Mickey", "Silver", "Simba", "Stitch" };
string mas3[9] = { "Dumbo", "Genie", "Jiminy", "Kuzko", "Kida", "Kenai", "Tarzan", "Tiana","Winnie" };
for (int i = 0; i < 9; i++) {
if (name == mas1[i])return 1;
if (name == mas2[i])return 2;
if (name == mas3[i]) return 3;
}
}
int main() {
int N, s=0,a1=1,a2=1;
string name;
cin >> N;
for (int i = 0; i < N; i++) {
cin>>name;
a2=shkaf(name);
s += abs(a2 - a1);
a1 = a2;
}
cout << s;
return 0;
}