1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 char p_code[] = {'_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','.'}; 6 int c_code[100]; 7 int ans[100]; 8 9 int main() 10 { 11 //freopen("acm.acm","r",stdin); 12 int k; 13 int n; 14 int i; 15 string s; 16 17 while(cin>>k,k) 18 { 19 cin>>s; 20 n = s.length(); 21 for(i = 0; i < n; ++ i) 22 { 23 if(s[i] >= 'a' && s[i] <= 'z') 24 { 25 c_code[i] = (s.at(i)-'a'); 26 ans[(k*i)%n] = (c_code[i]+1)%28+i; 27 } 28 else if(s[i] == '_') 29 { 30 ans[(k*i)%n] = (0+i); 31 } 32 else if(s[i] == '.') 33 { 34 ans[(k*i)%n] = (27+i); 35 } 36 } 37 for(i = 0; i < n; ++ i) 38 { 39 cout<<p_code[ans[i]%28]; 40 } 41 cout<<endl; 42 43 } 44 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com