[VIEWED 8210
TIMES]
|
SAVE! for ease of future access.
|
|
|
Sparty
Please log in to subscribe to Sparty's postings.
Posted on 12-09-14 11:14
AM [Snapshot: 178]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
I don't know if this will help you in your assignment. I can't write in C++, but here is the algorithm that I would use to write in my choice of language. 1. declare a string with alphabets, s = "abcd....z" 2. read the characters in your code one by one and count them 3. The most frequently used letter is 'e' (roughly 12%) 4. based on that I would find the rotation of the character in your code. By rotation I mean find the index of your character in the string 's' and subtract index of e, in this case it is 4. 5. Now shift each of your characters by that rotation, but leave the punctuations and blank spaces as they are. 6. After decoding see if it makes sense. This might not work in your code, but you can give it a try. Hope that helps
|
|
|
|
Sparty
Please log in to subscribe to Sparty's postings.
Posted on 12-09-14 11:56
AM [Snapshot: 184]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
By the way using the language that I use, I could partially decode it. Here is the decoded part if that helps this is a sample input file for cosc 587: assignment '542 ]our program should encode this file b} adding four to the ascii value of each character in it2 in }our encoded file the first character should be +\+2 the last character of the first line should be +>+2 the encoded file should have < lines of te|t just like this one0 but {ill be unreadable2 the last character of the last line {ill be a +6+2 I think the algorithm that I mentioned earlier needs some refinement, but you got the point that I was trying to convey. Good luck with your assignment
|
|
|
prankster
Please log in to subscribe to prankster's postings.
Posted on 12-09-14 12:17
PM [Snapshot: 186]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|
|
djblade
Please log in to subscribe to djblade's postings.
Posted on 12-09-14 12:23
PM [Snapshot: 203]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
I have the encrypted file in code.txt which is in same directory as source.cpp file. My code is supposed to ifstream encoded file and subtract 4 form ASCII value of each character. The output of the decoded file will in turn be stored in same directory as file plain2.txt
|
|
|
prankster
Please log in to subscribe to prankster's postings.
Posted on 12-09-14 12:28
PM [Snapshot: 195]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
you do the reading from file part, I just assigned input the variable, #include
using namespace std;
int main() { char c[] = "Xlmw$mw$e$weqtpi$mrtyx$jmpi$jsv$GSWG$587:ewwmkrqirx$\'542$]syv$tvskveq$wlsyph$irgshi$xlmwjmpi$f}$ehhmrk$jsyv$xs$xli$EwGMM$zepyi$sj$iegl$glevegxiv$mr$mx2$Mr$}syv$irgshih$jmpi$xli$jmvwx$glevegxiv$wlsyph$fi$+\+2$Xli$pewx$glevegxiv$sj$xli$jmvwx$pmri$wlsyph$fi$+>+2Xli$irgshih$jmpi$wlsyph$lezi$<$pmriw$sj$xi|x$nywx$pmoi$xlmw$sri0fyx${mpp$fi$yrviehefpi2$Xli$pewx$glevegxiv$sj$xli$pewx$pmri${mpp$fi$e$+6+2"; for (int i = 0; i< sizeof c; i ++) { char decodedString = c[i] - 4; cout << decodedString; } return 0; }
The output was: This is a sample input file for #10. Your program should encode our to the AsCII value of each c our encoded file the first chara he last character of the first l e encoded file should have 8 lin
|
|
|
prankster
Please log in to subscribe to prankster's postings.
Posted on 12-09-14 12:32
PM [Snapshot: 212]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
If you want to learn file handling in c++, http://www.tutorialspoint.com/cplusplus/cpp_files_streams.htm
|
|
|
prankster
Please log in to subscribe to prankster's postings.
Posted on 12-09-14 12:37
PM [Snapshot: 213]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Seems the output got truncated, here is the correct output, This is a sample input file for COSC 1436assignment #10. Your program should encode thisfile by adding four to the AsCII value of each character in it. In your encoded file the first character should be '. The last character of the first line should be ':'.The encoded file should have 8 lines of text just like this one,but will be unreadable. The last character of the last line will be a '2'.�
|
|
|
djblade
Please log in to subscribe to djblade's postings.
Posted on 12-09-14 2:09
PM [Snapshot: 256]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Prankster bro, hands down you are the best. Genius
|
|
|