Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. string a;
  2.  
  3. function setA(string memory x)public{
  4. a = x;
  5. }
  6.  
  7. function reverseStr() public view returns(string memory){
  8. bytes memory entString = bytes(a);
  9.  
  10. string memory revStrings =new string(entString.length);
  11.  
  12. bytes memory revString = bytes(revStrings);
  13.  
  14. uint k=0;
  15. require(revString.length>0);
  16.  
  17. for(uint i=revString.length;i>0 ;i--){
  18. revString[k++] = entString[i];
  19. }
  20.  
  21. return string(revString);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement