View Single Post
Re: Show off your finest piece of code!
Old
  (#5)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Show off your finest piece of code! - 29-12-2004

Code:
#include <iostream>
   #include <stdlib.h>
   
   #define BIT0 1
   #define BIT1 2
   #define BIT2 4
   #define BIT3 8
   #define BIT4 16
   #define BIT5 32
   #define BIT6 64
   #define BIT7 128
   
   using namespace std;
   
   int main(void)
   {
     char AsciiStorageArray[256];
     cout << "Insert the phrase to be translated: ";
     cin.getline(AsciiStorageArray, 255);
     cout << endl << "Streaming: ";
     
     int i;
     for (i=0; i < 256; i++)
     {
   	if (AsciiStorageArray[i] == 0)
   	  break;
   	if (AsciiStorageArray[i] & BIT7)
   	  cout << 1;
   	else
   	  cout << 0;
   	if (AsciiStorageArray[i] & BIT6)
   	  cout << 1;
   	else
   	  cout << 0;
   	if (AsciiStorageArray[i] & BIT5)
   	  cout << 1;
   	else
   	  cout << 0;
   	if (AsciiStorageArray[i] & BIT4)
   	  cout << 1;
   	else
   	  cout << 0;
   	if (AsciiStorageArray[i] & BIT3)
   	  cout << 1;
   	else
   	  cout << 0;
   	if (AsciiStorageArray[i] & BIT2)
   	  cout << 1;
   	else
   	  cout << 0;
   	if (AsciiStorageArray[i] & BIT1)
   	  cout << 1;
   	else
   	  cout << 0;
   	if (AsciiStorageArray[i] & BIT0)
   	  cout << 1;
   	else
   	  cout << 0;
   	cout << " ";
     }
     
     cout << endl << "Thank you and have a very safe day" << endl;
     
     system("PAUSE");	
     return 0;


sfx1999.postcount++
  
Reply With Quote