急,如何实现题中的对应

本关任务:输入一个四位数,将其加密后输出。加密方法是首先将该数每一位上的数字加 13 得到一个数,然后转换成对应的大写英文字母。1对应’A’,2对应’B’,……,26对应’Z’。


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

int  main()
{
    char arr[4];
    cout << "输入一个四位数字:" << endl;
    cin >> arr;

    for (char c : arr)
    {
        cout << char(c + 17);
    }
    cout << endl;

    system("pause");
    return 0;
}

img

#include <iostream>
using namespace std;
int main()
{
    int n;
    char ch[5] = {0};
    int i=3;
    cin>>n;
    whlie(n>0)
    {
          ch[i--] = (n%10+13)%26+'A';
          n=n/10;
    }
    cout<<ch;
    return 0;
}

到不了26吧。。