CALL-ME-OLIVIA / new-ideas-or-classic-ideas

1 stars 0 forks source link

字母循环,时间循环两种剪掉周期的方式 #24

Closed CALL-ME-OLIVIA closed 1 week ago

CALL-ME-OLIVIA commented 1 week ago

1.优点,可以知道循环次数,用以进位

while (n >= 60)//110
        {
            hour++;//12
            n -= 60;//50
        }

if ((n + minute) >= 60)//70
        {
            hour++;//13
            minute = n + minute - 60;//10
        }

2.优点,更快,无需循环 offest %= 26;

if (offest >= 0) { str[i] = (str[i] - 'a' + offest) % 26 + 'a'; } else { str[i] = (str[i] - 'a' + offest+26 ) % 26 + 'a'; }``