10677 we still do not know the name of the flower saw that day
Time limit: 1000MS Memory Limit: 65535K
Questions: Programming language title: Unlimited
Description
Between bud, Jen too, Bobo, Ann Ming, snow collection, Tsurumi is the former childhood always play together together with six friends. Since childhood accident, everyone's relationship lopsided.
As time goes by, they are ideal for their own lives and went their separate ways.
One day, between shoots to leave you, and she gave us each left an e-mail. At this time, the snow set in brand-name high school reading, relied on their own computer knowledge,
The e-mail content to Jen too (sentence) encrypted.
Then he left a piece of encrypted program because he wanted to see the benevolence too ordinary schools can not be decrypted out.
But the fact is, the school's brand name or not is not the most important, important is their own individual efforts. To see their letter to the inter-buds, Jen too specialized to learn the C language,
Then decrypt that sentence out. You can do it?
Input
The following is a set of snow encrypted code:
void Encrypt(char msg[])
{
char key[] = "sleepiforest";
int msgLen = strlen(msg);
int keyLen = strlen(key);
int offset;
for(offset=0;offset<msgLen;++offset)
{
msg [offset] ^ = key [offset% keyLen]; // ^ is an exclusive-OR operation
}
for(offset=0;offset<msgLen;++offset)
{
printf ( "% 02x", msg [offset]); //% x hexadecimal
}
}
Mail between the bud the contents of the msg passed to the function above, the following output.
53 30 39 59 0e 48 18 4f 34 0a 01 13 16 18 48 28 15 44 28 00 06 45 0d 55 0d 52 4a 4a 50 you can output the decrypted original text msg out of it?
Output
According encryption, decryption of these words, and then output it can be.
For example: Suppose the decryption out of this sentence is "WELCOME TO THE TEAM OF SCAU_ACM".
Then you just need to put that output on it.
Provide a template:
#include <stdio.h>
int main ()
{
char msg[] = "WELCOME TO THE TEAM OF SCAU_ACM";
puts(msg);
return 0;
}
Msg just need to replace the contents of the decrypted content you out, you can submit through.
Sample Input
no
Sample Output
According to subject the output
Hint
A character can not leak, so it can not be wrong oh ~ ~ ~ ~ better to output the decrypted string in the decryption program in it ~
Code that provides a data entry:
char bin[] = "53 30 39 59 0e 48 18 4f 34 0a 01 13 16 18 48 28 15 44 28 00 06 45 0d 55 0d 52 4a 4a 50";
char msg[50];
int len = (strlen (bin) +1) / 3;
for(int i=0;i<len;++i)
{
Here you can use the data in the bin sscanf entered into msg ~~ specific usage you check the information it ~ ~
}
// In fact, she used to encrypt or different, but I can take her again with keyLen [] with the results once the exclusive OR XOR to return to the original msg [] a
// The following is the code AC
#include<stdio.h>
#include<string.h>
void transto_orimsg(char msg[],int msgLen)
{
char key[] = "sleepiforest";
int keyLen = strlen(key);
int offset;
for(offset=0;offset<msgLen;++offset)
{
msg [offset] ^ = key [offset% keyLen]; // ^ is an exclusive-OR operation
}
printf("%s\n",msg);
}
int main ()
{
int i,k=0;
char bin[] = "53 30 39 59 0e 48 18 4f 34 0a 01 13 16 18 48 28 15 44 28 00 06 45 0d 55 0d 52 4a 4a 50";
char msg[150]={'\0'};
int len = strlen (bin);
for(i=0;i<len;i+=3)
sscanf(&bin[i],"%x",&msg[k++]);
transto_orimsg(msg,k);
return 0;
}
Reproduced in: https: //www.cnblogs.com/arcfat/archive/2012/11/07/2759071.html