[hackerrank]The Love-Letter Mystery

https://www.hackerrank.com/contests/w3/challenges/the-love-letter-mystery

简单题。

#include <cstdlib>
#include <string>
#include <iostream> using namespace std; int main() {
int N;
cin >> N;
while (N--) {
string s;
cin >> s;
int count = 0;
int l = 0;
int r = s.size() - 1;
while (l < r) {
count += abs(s[l++] - s[r--]);
}
cout << count << endl;
}
return 0;
}

  

上一篇:图论 ---- spfa + 链式向前星 ---- poj 3268 : Silver Cow Party


下一篇:Selenium2+python自动化11-定位一组元素find_elements