
No se cual es el error en SUBTITUTION CS50 el link esta en la description
Publicado por Juan (1 intervención) el 20/04/2022 07:20:09
Yo estoy haciendo el curo de cs50 pero no se porque a pesar de que se imprime todo perfecto cuando corro el codigo manualamente cuando lo hace la computadora para calificarme me sal como si esta mal me sale que hay errores , este ejercicio es el de substitution de cs50 se lo puede encontrar aca https://cs50.harvard.edu/x/2022/psets/2/substitution/ nose porque no me sale como que si mi codigo esta correcto
[u]En la terminal una vez que ejecuto el codigo me sale esto---->
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[])
{
// check that the lenght of the argc is 2, if not print ./substitucion KEY
if (argc != 2)
{
printf("./substitucion KEY\n");
return 1;
}
// Check that the lenght of the key is == 26 if not, print THE KEY MUST BE 26
if (strlen(argv[1]) != 26)
{
printf("The key must contain 26 letters\n");
return 1;
}
// SAVE THE KEY AS KEY ARV[1] = KEY
string key = argv[1];
// check if the key is alphabetical
for (int x = 0; x < strlen(key); x++)
{
if (!isalpha(key[x]))
{
printf("It must contain only alphabetical letters\n");
return 1;
}
}
// Check that each letter of the key is unique
for (int y = 0; y < strlen(key); y ++)
{
for (int u = y + 1; u < strlen(key); u++)
{
if (toupper(key[y]) == toupper(key))
{
printf("The key alphabet can only be repeated once\n");
return 1;
}
}
}
// ask the user ewhat will be the plain text
string plaintext = get_string("plaintext: ");
printf("ciphertext: ");
// encypher the plain text using an algorithm and print the cyphertext
for (int i = 0, len = strlen(plaintext) ; i <= len; i ++)
{
if (isupper(plaintext[i]))
{
int INDEX = (plaintext[i] - 'A');
printf("%c", toupper(key[INDEX]));
}
else if (islower(plaintext[i]))
{
int index = (plaintext[i] - 'a');
printf("%c", tolower(key[index]));
}
else
{
printf("%c", plaintext[i]);
}
}
printf("\n");
}
[u]En la terminal una vez que ejecuto el codigo me sale esto---->
substitution/ $ check50 cs50/problems/2022/x/substitution
Connecting.....
Authenticating...
Verifying.....
Preparing.............
Uploading.........
Waiting for results................................................
Results for cs50/problems/2022/x/substitution generated by check50 v3.3.5
:) substitution.c exists
:) substitution.c compiles
:( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key
expected "ciphertext: Z\...", not "ciphertext: Z\..."
:( encrypts "a" as "z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key
expected "ciphertext: z\...", not "ciphertext: z\..."
:( encrypts "ABC" as "NJQ" using NJQSUYBRXMOPFTHZVAWCGILKED as key
expected "ciphertext: NJ...", not "ciphertext: NJ..."
:( encrypts "XyZ" as "KeD" using NJQSUYBRXMOPFTHZVAWCGILKED as key
expected "ciphertext: Ke...", not "ciphertext: Ke..."
:( encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZTEOGXHCIPJSQD as key
expected "ciphertext: Cb...", not "ciphertext: Cb..."
:( encrypts "This is CS50" as "Cbah ah KH50" using yukfrnlbavmwzteogxhcipjsqd as key
expected "ciphertext: Cb...", not "ciphertext: Cb..."
:( encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZteogxhcipjsqd as key
expected "ciphertext: Cb...", not "ciphertext: Cb..."
:( encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key
expected "ciphertext: Rq...", not "ciphertext: Rq..."
:) handles lack of key
:) handles too many arguments
:) handles invalid key length
:) handles invalid characters in key
:) handles duplicate characters in key
:) handles multiple duplicate characters in key
To see the results in your browser go to https://submit.cs50.io/check50/17ccdf5f0a28464745324e3015b4a44bf7cd784d
Valora esta pregunta


0