Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. int main() {
  2.  
  3.  
  4. int i, n, len, pos, ops, end;
  5. scanf("%d",&n);
  6. char str[n][10000];
  7. char a,b;
  8. for (i=0;i<n;i++) {
  9. scanf("%s",str[i]);
  10. }
  11. for (i=0;i<n;i++) {
  12. len = strlen(str[i]);
  13. pos = 0;
  14. end = len - 1;
  15. ops = 0;
  16. while ( pos < end) {
  17. a = str[i][pos];
  18. b = str[i][end];
  19. if ( a != b ) {
  20. if ( b > a )
  21. ops = ops + (b -a);
  22. else
  23. ops = ops + (a -b);
  24. }
  25. pos++;
  26. end--;
  27. }
  28. printf("%dn", ops);
  29. }
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement