怎么用c做这条题,已经困扰我两天了

教我https://img-mid.csdnimg.cn/release/static/image/mid/ask/998165000766113.jpg

是的,我来了!


#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
void Encrypt(char* a, char* b)
{
    int i = 0;
    printf("加密后的结果为:");
    for (i = 0; i < 6; i++)
    {
        char y = 0;
        int x = *(a + i) + *(b + i);
        if (x <= 127)
        {
            y = (char)x;
        }
        else
        {
            y = (char)(x - 127);
        }
        printf("%c ", y);
    }
    printf("\n");
}
int main()
{
    char text[7] = { 0 };
    char password[7] = { 0 };
    printf("请输入6个字符作为文本>");
    scanf("%c %c %c %c %c %c", &text[0], &text[1], &text[2], &text[3], &text[4], &text[5]);
    printf("请输入6个字符作为密码>");
    int bin = getchar();
    scanf("%c %c %c %c %c %c", &password[0], &password[1], &password[2], &password[3], &password[4], &password[5]);
    Encrypt(text,password);
    return 0;
}

#include <stdio.h>
int main() {
    unsigned char s[7];
    unsigned char m[7];
    unsigned char d[7];
    int i,c;

    scanf("%6s",s);
    scanf("%6s",m);
    for (i=0;i<6;i++) {
        c=s[i]+m[i];
        if (c>127) {
            c=c-127;
            c=s[i]+c;
        }
        d[i]=c;
    }
    d[6]=0;
    printf("%s\n",d);
    return 0;
}