Guest User

Untitled

a guest
Mar 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<math.h>
  5. void main(){
  6. int i,j,k,n,c=0;
  7. printf("enter no of queries.....");
  8. scanf("%d",&n);
  9. int a[n];
  10. for(k=0;k<n;k++){
  11. char *s;
  12. s=(char*)malloc(10000*sizeof(char));
  13. // printf("enter string....");
  14. scanf("%s",s);
  15. i=0;j=strlen(s)-1;c=0;
  16. while(i<j){
  17. c+=abs(s[i]-s[j]);
  18. i++;
  19. j--;
  20. }
  21. a[k]=c;
  22. }
  23. for(i=0;i<n;i++){
  24. if(i==n-1)
  25. printf("%d",a[i]);
  26. else
  27. printf("%d\n",a[i]);
  28. }
  29.  
  30. }
Add Comment
Please, Sign In to add comment