1 include 2 include 3 4 using namespace std 5 6 int main 7

1 #include<iostream>
2 #include<string>
3
4 using namespace std;
5
6 int main()
7 {
8 char message[100];
9 char output[100];
10
11 int key, count;
12
13 cout << \"Enter encrypted message : \";
14 cin.getline(message,100);
15
16 for(key = 1; key <= 100; key++)
17 {
18 for(count = 0; message[count] !=\'\\0\'; count++)
19 {
20 if(message[count] - key < 32)
21 output[count] = message[count] - key + 127 - 32;
22 else
23 output[count] = message[count] - key;
24 }
25
26 cout << \"Decrypted message using Key \" << key << \" : \";
27 cout << output << endl;
28 }
29
30 }

can you help me separate these into 3 functions? I keep getting errors.

Solution

#include 02 #include 03 using namespace std; 04 int main() 05 { 06     string message, decrypt; 07     int m, d, shift, n = 0; 08     ifstream input; 09       10     //read encrypted message from \"secret.dat\" 11     input.open(\"secret.dat\"); 12     getline(input, decrypt, \'&\'); 13     getline(input, message); 14     input.close(); 15       16     cout << \"encrypted message is: \" << decrypt << endl; 17 18     //get shifting factor 19     m = message.length(); 20     d = decrypt.length(); 21     if (message[m - 2] == 79) 22        shift = (message[m-1] - 48); 23     else if (message[m - 2] != 79) 24        shift = (((message[m - 2] - 48) * 10) + (message[m-1]- 48)); 25 26          27     for (int i = 0; i < d; i++) 28     { 29         //decrypt[i] = decrypt[i] - shift; 30           31         if ((decrypt[i] > 64) && (decrypt[i] < 91))//letters 32             { 33             decrypt[i] = decrypt[i] - shift; 34 35               while ((decrypt[i] > 57) && (decrypt[i] < 65)) 36                  decrypt[i] = decrypt[i] + 26; 37             } 38         if ((decrypt[i] > 47) && (decrypt[i] < 58))//numbers 39            {       40             decrypt[i] = decrypt[i] - shift; 41               42               while ((decrypt[i] < 48) && (decrypt[i] > 32)) 43                  decrypt[i] = decrypt[i] + 10; 44                              45             } 46          47         if((decrypt[i] > 64) && (decrypt[i] < 91)) 48         if (decrypt[i-1] + 4 == decrypt[i] + shift) 49            decrypt[i] = 32; 50              51                       { 52                            if (decrypt[i] + shift > 90) 53                               decrypt[i] = 32; 54                                 55                            if (decrypt[i] + shift < 48) 56                              decrypt[i] = 32; 57                            if (decrypt[i-1] + 4 == decrypt[i]) 58                               decrypt[i] = 32; 59                             60                            } 61                62             if ((decrypt[i] > 47) && (decrypt[i] < 58)) 63              if(decrypt[i-1]==32) 64              decrypt[i+1]=32;      65 66     }   67     cout << \"decrypted message is: \" << decrypt << endl; 68     system(\"pause\"); 69     return 1; 70 }
1 #include<iostream> 2 #include<string> 3 4 using namespace std; 5 6 int main() 7 { 8 char message[100]; 9 char output[100]; 10 11 int key, count; 1

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site