首页 > 其他 > 详细

The Love-Letter Mystery

时间:2014-09-25 23:13:59      阅读:419      评论:0      收藏:0      [点我收藏+]

The Love-Letter Mystery

#include<cmath>
#include<cstdio>
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;


int main() {
    int T;
    cin>>T;
    string str;
    getline(cin,str);
        
    while(T--)
    {

        string str1;
        int count;
        getline(cin,str1);
        count = str1.length() ;
    
        
        int sum = 0,n = 0;
        int j = count/2;
        for(int i = 0;i < j ;i++)
        {
            if(static_cast<int>(str1[count - 1 - i]) >= static_cast<int>(str1[0 + i]))
                {
                    n = static_cast<int>(str1[count - 1 - i] - str1[0 + i]);
                    sum += n;
                }
            else
                {
                    n = static_cast<int>(str1[0 + i]) - static_cast<int>(str1[count - 1 - i]);
                    sum += n;
                }
        }
        cout<<sum<<endl;

    }
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    return 0;
}


The Love-Letter Mystery

原文:http://9320314.blog.51cto.com/9310314/1558253

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!