用 C

问题描述

我想用 C 语言为凯撒密码构建一个解码器。我现在的代码如下所示:

#include <stdio.h>
#include <string.h>

int main(){
    
    char str[100];
    int i;
    
    
    printf("Please enter the message that you want to decrypt: \n\n");
    
    fgets(str,100,stdin);
    
    printf("Please enter the letter shift\n\n");
    scanf("%d",&i);
    
    switch (i) {
        case 1:
            for(i = 0; (i < 100 && str[i] != '\0'); i++)
              str[i] = str[i] - 15;
            break;
            
        default:
            
            printf("\nError\n");
            break;
    }
    
    
    printf("The decoded message is: \n\n");
    printf("%s\n\n",str);
    
    
   return 0;
}

问题是:程序仍然给我发回加密消息。我可以做些什么来改进我的代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)