Выводит на экран таблицу из 4-х столбцов (для новичков очень удобно) :
int unsigned int binary ASCII ( -128 - 127 ) ( 0 - 255 )
Код :
| Код | // Show_Binary_and_ASCII.cpp : Defines the entry point for the console application. //
#include <stdafx.h> #include <iostream> #include <cstdlib> using namespace std; int main() { char lette; int i, t; unsigned int j;
for ( i=-128, lette=-128, j=0; i<128; i++, lette++, j++ ) { cout << "\n " ; if ( i>=0 ) cout << " "; if ( i>-10 && i<10 ) cout << " "; if ( i>-100 && i<100 ) cout << " "; cout << i << " "; for ( t=128; t>0; t=t/2 ) { if ( i & t ) cout << "1"; else cout << "0"; } cout << " "; if ( j<100 ) cout << " "; if ( j<10 ) cout << " "; cout << j << " "; for ( t=128; t>0; t=t/2 ) { if ( j & t ) cout << "1"; else cout << "0"; } cout << " "; switch(i) { case 7 : cout << "\" bip \"" << lette; break; case 10 : cout << "\" \\n \"" << lette; break; default : cout << lette; break; } } cout << "\n\n " ; return 0; }
|
|