a065.
提款卡密碼
--
板橋高中教學題
| From: [140.112.240.58] |
發表日期
:
2018-09-18 19:54
#include<iostream>
#include<cstdlib>
#include<math.h>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;
int main()
{
int n,a[6],b[5];
string str;
while(cin>>str)
{
for(int i=0;i<=6;i++)
{
if(str[i]=='A')
a[i]=1;
else if(str[i]=='B')
a[i]=2;
else if(str[i]=='C')
a[i]=3;
else if(str[i]=='D')
a[i]=4;
else if(str[i]=='E')
a[i]=5;
else if(str[i]=='F')
a[i]=6;
else if(str[i]=='G')
a[i]=7;
else if(str[i]=='H')
a[i]=8;
else if(str[i]=='I')
a[i]=9;
else if(str[i]=='J')
a[i]=10;
else if(str[i]=='K')
a[i]=11;
else if(str[i]=='L')
a[i]=12;
else if(str[i]=='M')
a[i]=13;
else if(str[i]=='N')
a[i]=14;
else if(str[i]=='O')
a[i]=15;
else if(str[i]=='P')
a[i]=16;
else if(str[i]=='Q')
a[i]=17;
else if(str[i]=='R')
a[i]=18;
else if(str[i]=='S')
a[i]=19;
else if(str[i]=='T')
a[i]=20;
else if(str[i]=='U')
a[i]=21;
else if(str[i]=='V')
a[i]=22;
else if(str[i]=='W')
a[i]=23;
else if(str[i]=='X')
a[i]=24;
else if(str[i]=='Y')
a[i]=25;
else if(str[i]=='Z')
a[i]=26;
}
for(int j=0;j<=5;j++)
{
if(a[j]>a[j+1])
b[j]=a[j]-a[j+1];
else if(a[j]<=a[j+1])
b[j]=a[j+1]-a[j];
}
for(int k=0;k<=5;k++)
{cout<<b[k];
}
cout<<endl;
}
return 0;
}