fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string s="xyxxy";
  7. int n=s.size();
  8. int d[n];
  9. for(int i=0;i<n;i++){
  10. if(s[i]=='x'){
  11. d[i]=-1;
  12. }
  13. else if(s[i]=='y'){
  14. d[i]=1;
  15. }
  16. }
  17. for(int i=0;i<n;i++){
  18. cout<<d[i];
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
-11-1-11