zad19
gorazd
c_cpp
10 months ago
749 B
4
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