2018年5月12日 星期六

itsa63 5Decryption

#include<iostream>
#include<string>
using namespace std;

int main()
{
int sum,a,b;
string str;
sum = 0;
a = 0;
b = 0;
while(getline(cin,str))
{
sum += (str[0] - 48) * 1;
sum += (str[2] - 48) * 2;
sum += (str[3] - 48) * 3;
sum += (str[4] - 48) * 4;
sum += (str[6] - 48) * 5;
sum += (str[7] - 48) * 6;
sum += (str[8] - 48) * 7;
sum += (str[9] - 48) * 8;
sum += (str[10] - 48) * 9;
a = sum % 11;
if (str[12] != 'X')
b = str[12] - 48;
else
b = str[12] - 88;
if (a == b)
cout << "Pass" << endl;
else
cout << "Fail" << endl;
}
return 0;
}

沒有留言:

張貼留言