1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#ifndef POLYBIUS_H
#define POLYBIUS_H
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
typedef char square[6][6];
char Uppercase(char c) {
putchar (toupper (c));
if (c=='J') {
c = 'I';
}
return c;
} //done
void GetCoordinates(square s,
char c,
int& Digit1,
int& Digit2,
int r,
int co) {
for (int r=0; r<6; r++) {
for (int co=0; co<6; co++) {
if (c == s[r][co]) {
Digit1=r;
Digit2=co;
}
}
}
} //done
char GetCharacter(square s,
int digit1,
int digit2) {
return s[digit1][digit2];
} //done
bool InSquare(square s, char c, int r, int co) {
for (int r=1; r<6; r++) {
for (int co=1; co<6; co++) {
if (c == s[r][co]) {
return true;
}
}
}
return false;
}//done
void FillSquare(square s,
string keyword, int r, int co) {
cin >> keyword;
keyword.erase(remove_if(keyword.begin(), keyword.end(), isspace (), keyword.end());
for (int i=0; i<keyword.length(); i++) {
keyword[i]=Uppercase(keyword[i]);
}
int i=0;
for (int r=1; r<6; r++) {
for (int co=1; co<6; co++) {
while (InSquare(square s, keyword[i])) {
i++;
}
s[r][co]=keyword[i];
}
}
}
void Put(square s, int r, int co) {
cout << s[r][co];
}
#endif
|