简体   繁体   English

你好,有人介意解释一下这段代码是什么意思吗?

[英]hi there, would anyone mind explaining what this code means?

Essentially, my friend wrote this code and did what i had done in these three lines whereas mine was nearly a page, i don't understand what it means could someone help please.从本质上讲,我的朋友写了这段代码并完成了我在这三行中所做的事情,而我的几乎是一页,我不明白这意味着什么有人可以帮忙。

msg[i] = toupper(msg[i]);
msg[i] = ((msg[i] - 'A')+rotation)%26;
printf("%c", calpha[msg[i]]);
// convert a - z character to upper case A - Z
msg[i] = toupper(msg[i]);

// A - Z values are 65 - 90. Subtract from uppercase character 65 (which is A)
// which moves it to 0 - 25 range. Add some shift value to it (rotation)
// %26 brings it back to 0 - 25 range.
msg[i] = ((msg[i] - 'A')+rotation)%26;

// print calpha value for given index (our 0 - 25 result)
printf("%c", calpha[msg[i]]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM