In the language of cryptography, ciphertext refers to a message encoded with a particular key. Plaintext refers to the original, unencoded text. In this problem, both the ciphertext and the key are simply strings of upper-case characters. The ciphertext is generated from the plaintext by “adding” corresponding characters of the plaintext and the key together. If the plaintext is shorter than the key, only some of the key will be used. Similarly, if the plaintext is shorter than the key, the key will be used multiple times.
Plaintext: HELLO
Key: CATCA
Ciphertext: KFFOP
And to encode the plaintext “DOG” with the key “FIDO”:
Plaintext: DOG
Key: FID
Ciphertext: JXK
To add two letters together, use the following convention: A=1, B=2, …, Z=26. If the sum of two letters is greater than 26, subtract 26 from the sum. For example: A + E = 1 + 5 = 6 = F, and D + X = 4 + 24 = 28 = 2 = B.
Given a ciphertext/key pair, determine the corresponding plaintext.
Input Format :
Input will consist of pairs of lines, with the first line being the ciphertext and the second line being the key. Both will consist of only uppercase letters.
Output Format:
For each ciphertext/key pair, print the corresponding plaintext message.
Example:
Sample Input:
HELLO
CAT
Sample Output:
KFFOP
Code:
#include<stdio.h> #include<string.h> int main() { char p[50]={0},key[50]={0}; int x=0; char c[50]={0}; int i,l1,l2; scanf("%s",p); scanf("%s",key); l1=strlen(p); l2=strlen(key); if(l1<=l2) { goto END; } else if(l1>l2) { for(i=l2;i<l1;i++) { key[i]=key[x]; x++; } //printf("\n%s",key); goto END; } END: for(i=0;i<l1;i++) { p[i]=(int)p[i]-64; key[i]=(int)key[i]-64; c[i]=p[i]+key[i]; if(c[i]>26) c[i]=c[i]-26; c[i]=c[i]+64; printf("%c",c[i]); } return 0; }
This program has no compilation error. Vadidation is correct. But in my status window, it is showing only 80%. Dont know where i wen wrong. plss help me out
ReplyDeleteNo. I think this code should work without error. Please check once again.
ReplyDeleteYou are a life saver.Thanks a ton :D
ReplyDeleteneed a help in clearing a session at ee…can anyone help me out…please drop a mail on aravindan.ashok@gmail.com….i really dont know how to clear that ….
ReplyDeleteCOEPD is glad to announce BA Internship Programs (Self sponsored) for professionals who want to have hands on experience . We are providing this program accompanied by IT Companies. Presently this program is available in Hyderabad & Pune locations. This internship is intelligently dedicated to our avid and passionate participants predominantly acknowledging and appreciating the fact that they are on the path of making a career in Business Analyst discipline. This internship is designed to ensure that in addition to gaining the requisite theoretical knowledge, the readers gain sufficient hands-on practice and practical know-how to master the nitty-gritty of the Business Analyst profession. More than a training institute, COEPD today stands differentiated as a mission to help you "Build your dream career" - COEPD way.
ReplyDeletehttp://www.coepd.com/business-analyst-training-internships.html
I was recommended this web site by means of my cousin. I am now not certain whether this post is written through him as nobody else recognise such precise about my difficulty. You're amazing! Thank you!
ReplyDeleteangularjs Training in bangalore
angularjs Training in electronic-city
angularjs Training in online
angularjs Training in marathahalli
I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favourites blog site list and will be checking back soon.
ReplyDeletePython training in marathahalli | Python training institute in pune
Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
ReplyDeleteJava training in Tambaram | Java training in Velachery
Java training in Omr | Oracle training in Chennai
Thank you for an additional great post. Exactly where else could anybody get that kind of facts in this kind of a ideal way of writing? I have a presentation next week, and I’m around the appear for this kind of data.
ReplyDeleteData Science training in rajaji nagar | Data Science with Python training in chenni
Data Science training in electronic city | Data Science training in USA
Data science training in pune | Data science training in kalyan nagar
Thanks for sharing such an awesome Information with us
ReplyDeleteI Got Job in my dream company with decent 12 Lacks Per Annum salary, I have learned this world most demanding course out there in the current IT Market from the Big Data Training In Bangalore Providers who helped me a lot to achieve my dreams comes true. Really worth trying.
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...Keep sharing!!
ReplyDeleteThanks for sharing such an awesome Information with us