Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <fstream>
  2. #define nmax 1000005
  3. using namespace std;
  4. ifstream cin("robot3.in");
  5. ofstream cout("robot3.out");
  6. int p,t,a[10],k=0,nrc,n,dd,ds;
  7. char dir,cif;
  8. int main()
  9. {
  10. cin>>t;
  11. if(t==1)
  12. {
  13. do
  14. {
  15. cin>>dir;
  16. if(dir=='A')
  17. k++;
  18. }while(dir!='T');
  19. cout<<k;
  20. }
  21. else
  22. {
  23. if(t==2)
  24. {
  25. nrc=0;
  26. do
  27. {
  28. cin>>dir;
  29. if(dir=='D')
  30. {
  31. cin>>p;
  32. nrc=(nrc+p)%10;
  33. }
  34. if(dir=='S')
  35. {
  36. cin>>p;
  37. nrc=(nrc-p+10)%10;
  38. }
  39. if(dir=='A')
  40. cout<<nrc;
  41. }while(dir!='T');
  42. }
  43. else
  44. {
  45. if(t==3)
  46. {
  47. nrc=0;
  48. while(cin>>cif)
  49. {
  50. int x=cif-'0';
  51. dd=(x-nrc+10)%10;
  52. ds=(nrc-x+10)%10;
  53. if(dd==0 ||ds==0)
  54. {
  55. cout<<"A";
  56. }
  57. else
  58. if(dd<=ds)
  59. {
  60. cout<<"D"<<dd<<"A";
  61. }
  62. else
  63. {
  64. cout<<"S"<<ds<<"A";
  65. }
  66. nrc=x;
  67. }
  68. cout<<"T";
  69.  
  70. }
  71. }
  72. }
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement