Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int pomjereno (char a, char b)
- {
- int a1, a2, a3, a4;
- int c[10][10];
- int d = 65;
- for (int i=0; i<5; i++)
- for (int j=0; j<6; j++)
- {
- c[i][j] = d;
- d = d + 1;
- }
- c[4][2]= ' ';
- c[4][3]= '-';
- c[4][4]= '.';
- c[4][5]= 'e';
- for(int i=0; i<5; i++)
- for(int j=0; j<6; j++)
- if (c[i][j] == a)
- { a1 = i;
- a2 = j;}
- for(int i=0; i<5; i++)
- for(int j=0; j<6; j++)
- if (c[i][j] == b)
- { a3 = i;
- a4 = j;}
- int s = 0;
- if (a1-a3 < 0)
- s = s + (a1-a3)*(-1);
- else s = s + a1-a3;
- if (a2-a4 < 0)
- s = s + (a2-a4)*(-1);
- else s = s + a2-a4;
- return s;
- }
- main()
- {
- char a[10][10];
- string ab;
- getline(cin, ab);
- /* int s = 65;
- for (int i=0; i<5; i++)
- for (int j=0; j<6; j++)
- {
- a[i][j] = s;
- s = s + 1;
- }
- a[4][2]= ' ';
- a[4][3]= '-';
- a[4][4]= '.';
- a[4][5]= 'e';
- for (int i=0; i<5; i++)
- {
- for (int j=0; j<6; j++)
- cout << a[i][j] << " ";
- cout << endl;
- } */
- int d = 0;
- d = pomjereno('A', ab[0]);
- for (int i=0; i<ab.length()-1; i++)
- d = d + pomjereno(ab[i], ab[i+1]);
- d = d + pomjereno(ab[ab.length()-1], 'e');
- cout << d << endl;
- system ("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement