Advertisement
a53

polybius

a53
Oct 2nd, 2019
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstring>
  3. using namespace std;
  4. char s[1000001];
  5.  
  6. int main()
  7. {
  8. char t[25];
  9. int p;
  10. ifstream f("polybius.in");
  11. f>>p>>t>>s;
  12. unsigned int L=strlen(s);
  13. ofstream g("polybius.out");
  14. if(p==1)
  15. {
  16. int n;
  17. int F[27]={0};
  18. for(unsigned int i=0;i<25;++i)
  19. n=t[i]-'A'+1,F[n]=(i/5+1)*10+i%5+1;
  20. for(unsigned int i=0;i<L;++i)
  21. g<<F[s[i]-'A'+1];
  22. }
  23. else
  24. {
  25. for(unsigned int i=0;i<L;i+=2)
  26. g<<t[(s[i]-'0'-1)*5+(s[i+1]-'0'-1)];
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement