Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 10-17-09   #11 (permalink)
Security Sleuth
 
Pooping^fish's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: egypt
Posts: 1,267

Rep: 67 Pooping^fish is acknowledged by some
Unique Rep: 62
Trader Rating: 3
Default

Shift cipher, classic. Why not throw your own spin on it?
__________________
Quote:
"O, hai! Want som pRon? Dwnlod ths kodk frst. Its teh bst pRonz ever, we prmis." -GibbyGano
Proud Member of the Linux Gaming Community
I am your friend.

System: ragequit
CPU
Q9550 4ghz @ 1.25v
Motherboard
Asus Max 2 formula
Memory
OCZ LV blade 1:1 950mhz
Graphics Card
8800gtx 610/1ghz
Hard Drive
7200.10 250gb
Sound Card
X-FI Extreme Music
Power Supply
750w Toughpower
Case
Lian li pc-65
CPU cooling
TRUE
GPU cooling
stock
OS
leetlinucks
Monitor
24" Westy
Pooping^fish is offline   Reply With Quote
Old 10-17-09   #12 (permalink)
Folding Fanatic
 
tofunater's Avatar
 
intel nvidia

Join Date: Sep 2006
Location: Dekalb, IL
Posts: 2,474

Rep: 203 tofunater is acknowledged by manytofunater is acknowledged by manytofunater is acknowledged by many
Unique Rep: 176
Folding Team Rank: 280
Trader Rating: 24
Default

Quote:
Originally Posted by newbie1911 View Post
upper case letters seem to work fine.
capitals all work, and lowercase d-z work. Everything else is fubar'd
__________________

Quote:
Originally Posted by iandh View Post
People like this know deep down inside that they are absolutely worthless, so they must constantly come up with new ways to give themselves worth, otherwise they may be tempted to end it all one day by OD'ing on Care-Bears marathons.

System: Hedonism, Stanford Style
CPU
i7 920 D0
Motherboard
Asus P6T6 WS revolution
Memory
6 gigs G-skill
Graphics Card
Tri-sli 260's
Hard Drive
620aaks
Sound Card
on board
Power Supply
Zalman 850
Case
hardwood techstation(soon)
CPU cooling
GTZ/bix 360/355 (soon)
GPU cooling
water (soon)
OS
Vista 64
Monitor
22" Samsung 225BW
Overclock.net - 2009 Chimp Challenge Champions
tofunater is offline I fold for Overclock.net   Reply With Quote
Old 10-17-09   #13 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 321

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default

found the problem with lover case ...
Code:
#include <iostream>
#include <iomanip>
#include <ctype.h>
using namespace std;
char revCaesar(char);
char convPunct(char);
char convDigit(char);
char convRest (char);
int main()
{
    char ch;
    cin >> ch;
    while (ch)
    {
          if (isalpha(ch))
                {
                 ch = revCaesar(ch);
                }
                
          else if (ispunct(ch))
                {
                 ch = convPunct(ch);
                }
                
          else if (isdigit(ch))
                {
                 ch = convDigit(ch);
                }
                
          else 
                {
                 ch = convRest(ch);
                }
                cout<<ch;
                cin>>ch;
    }
system ("pause");
return 0;
}
//Function 1 - undoes the Caesar Cipher
char revCaesar(char ch)
{
     if(isupper(ch))
            
           {
            if(ch >= 'D' && ch <= 'Z')
                  {
                   ch = ch - 3;
                   return ch;
                  }
            else
                
                switch(ch)
                            {
                            case 'A':
                            ch = 'X';
                            break;
                            case 'B':
                            ch = 'Y';
                            break;
                            case 'C':
                            ch = 'Z';
                            break;
                            }
            return ch;
           }
    if(ch >= 'd' && ch <= 'z')
          {
          ch = ch - 3;
          return ch;
          }
     else
         {
         switch(ch)
                   {
                   case 'a':
                   ch = 'x';
                   break;
                   case 'b':
                   ch = 'y';
                   break;
                   case 'c':
                   ch = 'z';
                   break;
                   }
         return ch;
         }
         
                            
            

}            

//Function 2 

char convDigit(char ch)
{

switch(ch)
{
case '0':
ch = ',';
break;
case '1':
ch = '.';
break;
case '2':
ch = '$';
break;
case '3':
ch = '&';
break;
case '4':
ch = '%';
break;
case '5':
ch = '*';
break;
case '6':
ch = '(';
break;
case '7':
ch = ')';
break;
case '8':
ch = '?';
break;
case '9':
ch = '!';
break;
}
return ch;
}
//Function 3

char convPunct(char ch)
{
switch(ch)
{
case '!':
ch = '0';
break;
case ',':
ch = '1';
break;
case ')':
ch = '2';
break;
case '(':
ch = '3';
break;
case '?':
ch = '4';
break;
case '-':
ch = '5';
break;
case '&':
ch = '6';
break;
case '$':
ch = '7';
break;
case '.':
ch = '8';
break;
case '+':
ch = '9';
break;
}
return ch;
}

//Function 4

char convRest(char ch)
{
if( int ch = 22)
{
    ch = ' ';
    return ch;
}

else if( int ch = 21)
{
     ch = '"\n"';
     return ch;
}

else
    return ch;
}
Code:
ch >= 'd' && ch <= 'z'
not
Code:
ch >= 'd' || ch <= 'z'
__________________
90% of statistics are made up on the spot. including this one.

Last edited by newbie1911 : 10-17-09 at 04:06 PM
newbie1911 is offline   Reply With Quote
Old 10-17-09   #14 (permalink)
Folding Fanatic
 
tofunater's Avatar
 
intel nvidia

Join Date: Sep 2006
Location: Dekalb, IL
Posts: 2,474

Rep: 203 tofunater is acknowledged by manytofunater is acknowledged by manytofunater is acknowledged by many
Unique Rep: 176
Folding Team Rank: 280
Trader Rating: 24
Default

that did it newbie, thanks. Any thoughts on the symbols and numbers?
__________________

Quote:
Originally Posted by iandh View Post
People like this know deep down inside that they are absolutely worthless, so they must constantly come up with new ways to give themselves worth, otherwise they may be tempted to end it all one day by OD'ing on Care-Bears marathons.

System: Hedonism, Stanford Style
CPU
i7 920 D0
Motherboard
Asus P6T6 WS revolution
Memory
6 gigs G-skill
Graphics Card
Tri-sli 260's
Hard Drive
620aaks
Sound Card
on board
Power Supply
Zalman 850
Case
hardwood techstation(soon)
CPU cooling
GTZ/bix 360/355 (soon)
GPU cooling
water (soon)
OS
Vista 64
Monitor
22" Samsung 225BW
Overclock.net - 2009 Chimp Challenge Champions
tofunater is offline I fold for Overclock.net   Reply With Quote
Old 10-17-09   #15 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 321

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default

couldn't find an bugs now. im confused about one part tho. why does it work with char arrays? i thought you needed to make a pointer to a char to input strings. also why does it go through every char in the array ?
__________________
90% of statistics are made up on the spot. including this one.
newbie1911 is offline   Reply With Quote
Old 10-17-09   #16 (permalink)
Folding Fanatic
 
tofunater's Avatar
 
intel nvidia

Join Date: Sep 2006
Location: Dekalb, IL
Posts: 2,474

Rep: 203 tofunater is acknowledged by manytofunater is acknowledged by manytofunater is acknowledged by many
Unique Rep: 176
Folding Team Rank: 280
Trader Rating: 24
Default

Not quite sure what you mean by all of that newbie, but here is a link to the assignment -->http://www.cs.niu.edu/~abyrnes/csci240/pgms/240pgm6.htm
__________________

Quote:
Originally Posted by iandh View Post
People like this know deep down inside that they are absolutely worthless, so they must constantly come up with new ways to give themselves worth, otherwise they may be tempted to end it all one day by OD'ing on Care-Bears marathons.

System: Hedonism, Stanford Style
CPU
i7 920 D0
Motherboard
Asus P6T6 WS revolution
Memory
6 gigs G-skill
Graphics Card
Tri-sli 260's
Hard Drive
620aaks
Sound Card
on board
Power Supply
Zalman 850
Case
hardwood techstation(soon)
CPU cooling
GTZ/bix 360/355 (soon)
GPU cooling
water (soon)
OS
Vista 64
Monitor
22" Samsung 225BW
Overclock.net - 2009 Chimp Challenge Champions
tofunater is offline I fold for Overclock.net   Reply With Quote
Old 10-17-09   #17 (permalink)
ATI Enthusiast
 
gamervivek's Avatar
 
intel ati

Join Date: Oct 2007
Posts: 1,880

Rep: 167 gamervivek is acknowledged by manygamervivek is acknowledged by many
Unique Rep: 131
Trader Rating: 0
Default

Quote:
Originally Posted by tofunater View Post
that did it newbie, thanks. Any thoughts on the symbols and numbers?
seem to be working fine for me.
__________________
there are only 10 kind of people in this world, those who understand ternary, those who don't, and then those who don't give a damn.

I see in Fight Club the strongest and smartest men who've ever lived. I see all this potential, and I see squandering...

old man look at my life, I'm a lot like you.

Ati Tray Tools vs CCC

System: living on the edge BSODs galore
CPU
e2140@3.2Ghz
Motherboard
abit IP35-E
Memory
4GB 667@800 5-5-5-15
Graphics Card
HIS IceQ4 4850
Sound Card
soundblaster live! 24-bit
Power Supply
Corsair 450VX@stock
CPU cooling
Q6600's HSF
OS
win xp 32 bit
gamervivek is offline   Reply With Quote
Old 10-17-09   #18 (permalink)
Folding Fanatic
 
tofunater's Avatar
 
intel nvidia

Join Date: Sep 2006
Location: Dekalb, IL
Posts: 2,474

Rep: 203 tofunater is acknowledged by manytofunater is acknowledged by manytofunater is acknowledged by many
Unique Rep: 176
Folding Team Rank: 280
Trader Rating: 24
Default

Quote:
Originally Posted by gamervivek View Post
seem to be working fine for me.
Really? you run this:

Code:
#include <iostream>
#include <iomanip>
#include <ctype.h>
using namespace std;
char revCaesar(char);
char convPunct(char);
char convDigit(char);
char convRest (char);
int main()
{
    char ch;
    cin >> ch;
    while (ch)
    {
          if (isalpha(ch))
                {
                 ch = revCaesar(ch);
                }
                
          else if (ispunct(ch))
                {
                 ch = convPunct(ch);
                }
                
          else if (isdigit(ch))
                {
                 ch = convDigit(ch);
                }
                
          else 
                {
                 ch = convRest(ch);
                }
                cout<<ch;
                cin>>ch;
    }
system ("pause");
return 0;
}
//Function 1 - undoes the Caesar Cipher
char revCaesar(char ch)
{
     if(isupper(ch))
            
           {
            if(ch >= 'D' and ch <= 'Z')
                  {
                   ch = ch - 3;
                   return ch;
                  }
            else
                
                switch(ch)
                            {
                            case 'A':
                            ch = 'X';
                            break;
                            case 'B':
                            ch = 'Y';
                            break;
                            case 'C':
                            ch = 'Z';
                            break;
                            }
            return ch;
           }
     else if(ch >= 'd' and ch <= 'z')
          {
          ch = ch - 3;
          return ch;
          }
     else
         {
         switch(ch)
                   {
                   case 'a':
                   ch = 'x';
                   break;
                   case 'b':
                   ch = 'y';
                   break;
                   case 'c':
                   ch = 'z';
                   break;
                   }
         return ch;
         }
         
                            
            

}            

//Function 2 

char convDigit(char ch)
{

switch(ch)
{
case '0':
ch = ',';
break;
case '1':
ch = '.';
break;
case '2':
ch = '$';
break;
case '3':
ch = '&';
break;
case '4':
ch = '%';
break;
case '5':
ch = '*';
break;
case '6':
ch = '(';
break;
case '7':
ch = ')';
break;
case '8':
ch = '?';
break;
case '9':
ch = '!';
break;
}
}
//Function 3

char convPunct(char ch)
{
switch(ch)
{
case '!':
ch = '0';
break;
case ',':
ch = '1';
break;
case ')':
ch = '2';
break;
case '(':
ch = '3';
break;
case '?':
ch = '4';
break;
case '-':
ch = '5';
break;
case '&':
ch = '6';
break;
case '$':
ch = '7';
break;
case '.':
ch = '8';
break;
case '+':
ch = '9';
break;
}
}

//Function 4

char convRest(char ch)
{
if( int ch = 22)
{
    ch = ' ';
    return ch;
}

else if( int ch = 21)
{
     ch = '"\n"';
     return ch;
}

else
    return ch;
}
And when you put in numbers or symbols it doesn't return anything bizarre?
__________________

Quote:
Originally Posted by iandh View Post
People like this know deep down inside that they are absolutely worthless, so they must constantly come up with new ways to give themselves worth, otherwise they may be tempted to end it all one day by OD'ing on Care-Bears marathons.

System: Hedonism, Stanford Style
CPU
i7 920 D0
Motherboard
Asus P6T6 WS revolution
Memory
6 gigs G-skill
Graphics Card
Tri-sli 260's
Hard Drive
620aaks
Sound Card
on board
Power Supply
Zalman 850
Case
hardwood techstation(soon)
CPU cooling
GTZ/bix 360/355 (soon)
GPU cooling
water (soon)
OS
Vista 64
Monitor
22" Samsung 225BW
Overclock.net - 2009 Chimp Challenge Champions
tofunater is offline I fold for Overclock.net   Reply With Quote
Old 10-18-09   #19 (permalink)
Programmer
 
newbie1911's Avatar
 
Join Date: Jul 2008
Posts: 321

Rep: 19 newbie1911 Unknown
Unique Rep: 17
Trader Rating: 0
Default

working perfectly fine for me. and the only things i changed from ur code is && instead of and also || instead of or ( visual c++ ) and i added
Code:
return ch;
after the while statements in conPunct and conDigit.
__________________
90% of statistics are made up on the spot. including this one.
newbie1911 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 07:57 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.14270 seconds with 8 queries