Added tolower() calls
This commit is contained in:
parent
23eac17117
commit
f17af835d4
2
brute.cc
2
brute.cc
@ -5,7 +5,7 @@ void shift(char* text, int key)
|
|||||||
std::cout << key << ": ";
|
std::cout << key << ": ";
|
||||||
for(int i = 0; text[i] != 0; ++i)
|
for(int i = 0; text[i] != 0; ++i)
|
||||||
{
|
{
|
||||||
char c = text[i]-key;
|
char c = std::tolower(text[i])-key;
|
||||||
if(c < 'a') c+=26;
|
if(c < 'a') c+=26;
|
||||||
if(c > 'z') c-=26;
|
if(c > 'z') c-=26;
|
||||||
std::cout << c;
|
std::cout << c;
|
||||||
|
3
shift.cc
3
shift.cc
@ -1,4 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -14,7 +15,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
for(int i = 0; text[i] != 0; ++i)
|
for(int i = 0; text[i] != 0; ++i)
|
||||||
{
|
{
|
||||||
char c = text[i]+key;
|
char c = std::tolower(text[i])+key;
|
||||||
if(c < 'a') c+=26;
|
if(c < 'a') c+=26;
|
||||||
if(c > 'z') c-=26;
|
if(c > 'z') c-=26;
|
||||||
std::cout << c;
|
std::cout << c;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
int keyvalue(char c)
|
int keyvalue(char c)
|
||||||
{
|
{
|
||||||
return c - 'a';
|
return std::tolower(c) - 'a';
|
||||||
}
|
}
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ int main(int argc, char** argv)
|
|||||||
int ki = 0;
|
int ki = 0;
|
||||||
for(int pi = 0; text[pi] != 0; ++pi)
|
for(int pi = 0; text[pi] != 0; ++pi)
|
||||||
{
|
{
|
||||||
char c = text[pi] + keyvalue(key[ki]);
|
char c = std::tolower(text[pi]) + keyvalue(key[ki]);
|
||||||
if(c < 'a') c+=26;
|
if(c < 'a') c+=26;
|
||||||
if(c > 'z') c-=26;
|
if(c > 'z') c-=26;
|
||||||
std::cout << c;
|
std::cout << c;
|
||||||
|
Loading…
Reference in New Issue
Block a user