a53

trifid

a53
Jan 5th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. int v[130];
  5. int s[4][10001];
  6. int v2[30001];
  7. char v3[334];
  8. int main()
  9. {
  10. ifstream cin ("trifid.in");
  11. ofstream cout ("trifid.out");
  12. int cer;
  13. cin>>cer;
  14. char c;
  15. for(int i=1;i<=3;i++)
  16. {
  17. for(int j=1;j<=3;j++)
  18. {
  19. cin>>c;
  20. v[(int)(c)]=100+j*10+i;
  21. v3[100+j*10+i]=c;
  22. }
  23. for(int j=1;j<=3;j++)
  24. {
  25. cin>>c;
  26. v[(int)(c)]=200+j*10+i;
  27. v3[200+j*10+i]=c;
  28. }
  29. for(int j=1;j<=3;j++)
  30. {
  31. cin>>c;
  32. v[(int)(c)]=300+j*10+i;
  33. v3[300+j*10+i]=c;
  34. }
  35. }
  36. if(cer==1)
  37. {
  38. char c1;
  39. int cnt=0,cnt1=0;
  40. while(cin>>c1)
  41. {
  42. cnt++;
  43. s[1][cnt]=v[c1]/100;
  44. s[2][cnt]=(v[c1]/10)%10;
  45. s[3][cnt]=v[c1]%10;
  46. }
  47. for(int i=1;i<=3;i++)
  48. {
  49. for(int j=1;j<=cnt;j++)
  50. {
  51. cnt1++;
  52. v2[cnt1]=s[i][j];
  53. }
  54. }
  55. for(int i=1;i<=cnt1;i+=3)
  56. {
  57. cout<<v3[v2[i]*100+v2[i+1]*10+v2[i+2]];
  58. }
  59. }
  60. if(cer==2)
  61. {
  62. char c1;
  63. int cnt1=0;
  64. while(cin>>c1)
  65. {
  66. cnt1++;
  67. v2[cnt1]=v[c1]/100;
  68. cnt1++;
  69. v2[cnt1]=(v[c1]/10)%10;
  70. cnt1++;
  71. v2[cnt1]=v[c1]%10;
  72. }
  73. int val=cnt1/3;
  74. for(int i=1;i<=val;i++)
  75. {
  76. cout<<v3[v2[i]*100+v2[i+val]*10+v2[i+val+val]];
  77. }
  78. }
  79. return 0;
  80. }
Add Comment
Please, Sign In to add comment