zad19

 avatar
user_1041599
c_cpp
a month ago
749 B
1
Indexable
2kolok_SP
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;

void transform(char* s,int x, int len) {
    if (len == 0) return;
    if (isalpha(s[0])) {
        if (isupper(s[0])) { //uppercase
            if (s[0]+x > 'Z') {
                s[0] -= (26-x);
            }
            else
                s[0] += x;
        }
        else {
            if (s[0]+x > 'z')
                s[0] -= (26-x);
            else
                s[0] += x;
        }
    }
    transform(s+1, x, len-1);
}

int main() {
    int n,x;
    cin>>n>>x;
    cin.ignore();
    char s[81];
    for(int i=0;i<n;i++) {
        cin.getline(s,81);
        int len = strlen(s);
        transform(s,x,len);
        cout<<s<<endl;
    }
}
Editor is loading...
Leave a Comment