记录编号 403591 评测结果 AAAAAAAAAA
题目名称 字符串编辑 最终得分 100
用户昵称 Gravatar亦不负卿 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2017-05-10 19:52:35 内存使用 0.31 MiB
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7. freopen("edit.in","r",stdin);
  8. freopen("edit.out","w",stdout);
  9. string a,n;
  10. getline(cin,a);
  11. char x,y,z;
  12. cin>>x;
  13. int m,k=0;
  14. if(x=='D')
  15. {
  16. cin>>y;
  17. m=a.find(y);
  18. a.erase(m,1);
  19. cout<<a;
  20. }
  21. if(x=='I')
  22. {
  23. cin>>y>>z;
  24. m=a.find_last_of(y);
  25. n=a.substr(m);
  26. a.erase(m);
  27. a=a+z+n;
  28. cout<<a;
  29. }
  30. if(x=='R')
  31. {
  32. cin>>y>>z;
  33. m=a.length();
  34. for(int i=0;i<m;i++)
  35. {
  36. if(a[i]==y)
  37. {
  38. k=1;
  39. a[i]=z;
  40. }
  41. }
  42. if(k==0)
  43. cout<<"error";
  44. else
  45. cout<<a;
  46. }
  47. return 0;
  48. }