【发布时间】:2014-03-27 06:30:27
【问题描述】:
我已经盯着这个问题看了好几个星期了,但我一无所获!它不起作用,我知道这么多,但我不知道为什么或出了什么问题。我确实知道开发人员对我突出显示的行吐出了“错误:预期的表达”,但实际上这只是冰山一角。如果有人知道如何解决这个问题,我将不胜感激!
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cs50.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
//Get the key
if (argc != 2 || atoi(argv[1]) < 0)
{
printf("Usage: ./caesar k");
return 1;
}
int key = atoi(argv[1]);
string plaintex;
string plaintext = GetString();
for (int i = 0, n = strlen(plaintext); n < i; i++)
{
if (plaintext[i] > 'A' && plaintext[i] <= 'Z')
{
plaintext[i] = (plaintext[i] - 'A' + key) % 26 + 'A';
}
}
for (int i = 0, n = strlen(plaintext); n < i; i++)
{
if (plaintext[i] >= 'A' && plaintext[i] >= 'Z') // Highlighted line
{
plaintext[i] = (plaintext[i] - 'A' + key) % 26 + 'A';
}
else if (plaintext[i] >= 'a' && plaintext[i] < 'z')
{
plaintext[i] = (plaintext[i] - 'a' + key) % 26 + 'a';
}
else
{
printf("%c\n", plaintext[i]);
}
}
return 0;
}
【问题讨论】:
-
无紧急情况。自公元前 44 年 3 月伊德斯以来,他就死了。
-
我想这是针对 OP 的,一旦他看到:您可能想阅读 meta.stackexchange.com/questions/10647/writing-good-titles/… ,如果您尝试从此处编辑问题,则有指向它的链接。
标签: c encryption cs50 caesar-cipher