字符平移

· · 个人记录

int n; //n是平移格数
cin >> n >> str;
for (int i = 0; s[i] != '\0'; i++)
    cout << (s[i] - 'a' + n) % 26 + 'a';