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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
void Decode(string numbers) {
}
void Encode(string words) {
string::size_type
loca=words.find("A",0),
locb=words.find("B",0),
locc=words.find("C",0),
locd=words.find("D",0),
loce=words.find("E",0),
locf=words.find("F",0),
locg=words.find("G",0),
loch=words.find("H",0),
loci=words.find("I",0),
locj=words.find("J",0),
lock=words.find("K",0),
locl=words.find("L",0),
locm=words.find("M",0),
locn=words.find("N",0),
loco=words.find("O",0),
locp=words.find("P",0),
locq=words.find("Q",0),
locr=words.find("R",0),
locs=words.find("S",0),
loct=words.find("T",0),
locu=words.find("U",0),
locv=words.find("V",0),
locw=words.find("W",0),
locx=words.find("X",0),
locy=words.find("Y",0),
locz=words.find("Z",0),
loc_=words.find(" ",0);
if (loca!=string::npos) loca=19;
if (locb!=string::npos) locb=28;
if (locc!=string::npos) locc=37;
if (locd!=string::npos) locd=46;
if (loce!=string::npos) loce=55;
if (locf!=string::npos) locf=64;
if (locg!=string::npos) locg=73;
if (loch!=string::npos) loch=82;
if (loci!=string::npos) loci=91;
if (locj!=string::npos) locj=19;
if (lock!=string::npos) lock=28;
if (locl!=string::npos) locl=37;
if (locm!=string::npos) locm=46;
if (locn!=string::npos) locn=55;
if (loco!=string::npos) loco=64;
if (locp!=string::npos) locp=73;
if (locq!=string::npos) locq=82;
if (locr!=string::npos) locr=91;
if (locs!=string::npos) locs=19;
if (loct!=string::npos) loct=28;
if (locu!=string::npos) locu=37;
if (locv!=string::npos) locv=46;
if (locw!=string::npos) locw=55;
if (locx!=string::npos) locx=64;
if (locy!=string::npos) locy=73;
if (locz!=string::npos) locz=82;
if (loc_!=string::npos) loc_=0;
cout << words;
}
int main() {
string ende;
cout << "Encode or Decode? [En/De]\n";
getline(cin, ende);
cin.clear();
if (ende=="En" || ende=="en") {
cout << "Enter a word or words to be encoded" << endl;
cout << "A file will be created afterwards.\n";
string words="";
getline(cin, words);
Encode(words);
}
else if (ende=="De" || ende=="de") {
cout << "This function is to decode a sequence of numbers, or to play around\n";
cin.clear();
cout << "Please enter a sequence of numbers: ";
string numbers;
getline(cin, numbers);
}
cin.ignore();
cin.get();
return 0;
}
|