C++ :: Array Of Hex Numbers Representing A Binary Number

Sep 24, 2013

So basically I have an array of hex numbers representing a binary number. Each binary number is 1/5th layer of the over all font.

For example... the letter A

........ B00000000 0x00
.****... B01111000 0x78
...*.*.. B00010100 0x14
...*..*. B00010010 0x12
...*.*.. B00010100 0x14
.****... B01111000 0x78
........ B00000000 0x00

As you can see each HEX number is a layer in the font which consists of in the above example 7 layers.

Now what I would like to do is create a C++ program, so I can visualize a HEX font array that I got off the internet.

#include <iostream>
using namespace std;
const char font[][5] = {
{0x00,0x00,0x00,0x00,0x00}, // 0x20 32
{0x00,0x00,0x6f,0x00,0x00}, // ! 0x21 33
{0x00,0x07,0x00,0x07,0x00}, // " 0x22 34
{0x14,0x7f,0x14,0x7f,0x14}, // # 0x23 35

[Code]...

Basically I am asking two things. How can I make this display the correct representing letter in the array when a user inputs his own text.

And secondly, how can I output the HEX numbers that is in the array as a binary number.

View 1 Replies


ADVERTISEMENT

C++ :: Random Numbers (Representing X And Y Co-ordinate) Grid Reference

Sep 18, 2013

How to code the following:

I have two random numbers which are generated and are related to each other (representing x and y co-ordinate). These random numbers are generated within a specified range: (-range, +range).

I want to categorize these values in a (2-dimensional) grid. The grid size is not definite and so can be varied by the user would be in the order of 400 x 400. (e.g., think CCD detector). For each random number pair (x, y) I want to store a hit (a plus one) in the corresponding grid reference.

In the order of 500,000 related random numbers (x and y) are to be generated and the position recorded according to grid reference. So code needs to be fast.

View 8 Replies View Related

C/C++ :: Use Binary Search To Find A Number In The Array?

Mar 23, 2014

i'm trying to use binary search to find a number in the array but i dont know whats wrong with my code. When l enter a number which DOES exist in the array, everything is ok... but when i enter a number which does NOT exist in the array, i have problem...i cant exit the program, it just continues to run.Here is my code

int main()
{
int FirstPosition;

[Code]....

View 2 Replies View Related

C/C++ :: Find Smallest Number In Array Filled With Random Numbers

Oct 24, 2014

I need to find the smallest number in my 10x8 arraygrid with random numebr filled in it

Here my Code:

#include <iostream>
using namespace std;
int main() {
int total,average,smallest;
int row=0;
int col=0;

[Code] ....

View 2 Replies View Related

C++ :: Array To Template Class - Finding Largest Number From A Group Of Numbers

Sep 26, 2013

I'm trying to make an array that takes a group of numbers and finds the largest number into a template class.

template<class TYPE>
void Integers(TYPE data) {
int integers[] = {4, 25, 32, 85, 150, 12, 98, 200};
int i = 0;
int Max=integers[0];
for (i=1; i < 8; i++) {

[Code] ....

I'm sure I'm going about it all wrong, but I'm not sure as to get it so that it will accept the arrays input.

View 2 Replies View Related

C++ :: Search User Input Number In Array Filled With Random Numbers

Nov 6, 2014

I need to create A program That makes a 12x10 Array Grid Filled With Random Numbers From 0-99.

Then I need To Allow The User To Input A Number Between 0-99 And Then The program will then search through the array and count how many of the users number there is inside the array.

Code:

#include <iostream>
using namespace std;
int main() {
int input;
int number;
int row=0;
int col=0;
int Array [12][10];

[Code] ....

View 1 Replies View Related

C/C++ :: Read Integers Into Array / Sort Numbers And Print Out Occurrence Of Each Number

Apr 6, 2014

My C programming class wants us to write a program to read integers into an array, sort the numbers and print out the occurrence of each number. I've tried everything that I can think of but the core dump is still occurring.

void countValues ( FILE *inf, int list[], int size ); /* Function prototypes. */
void printFrequencies( const int list[], int size );
int main (void) {
int status = EXIT_SUCCESS; /* defaulting status to success. */
FILE *inf = fopen( "numbers.txt", "r" ); /* input data file */

[Code] .....

View 6 Replies View Related

C++ :: Representing Entities With MI

Dec 24, 2013

I'm trying to make a space shooter and I want to make the code very reusable. So far I've been making a bunch of objects with multiple inheritance like this:

entity: anything which can be drawn, has a position and an orientation
solid: any entity which can collide with something else
mobile: any entity which can move
spriteEntity : an entity drawn using a sprite
vertexEntity : an entity drawn out of vertexes

The entity class has the virtual method draw, which gets defined by either spriteEntity or vertexEntity. mobile and solid virtually inherit from the entity class.

Then I could create a projectile class which inherits from solid and mobile but adds methods to damage stuff it collides with, and multiple subclasses which inherit from both projectile and spriteEntity... But I'm not sure if it's a good idea to go this deep in multiple inheritance for game objects. I know MI has a bad reputation.

I know that some objects of the game will be sprites and some will be vertexes, and I also know there will be stuff which collides and doesn't move... Or should I make the mobile class a subtype of solid?

View 6 Replies View Related

C++ :: Convert 8-digit Binary Number To Decimal Number?

Jul 6, 2013

Code: Complete the program below which converts a binary number into a decimal number. Sample outputs are shown belowComplete the program below which converts a binary number into a decimal number. Sample outputs are shown below.

Sample Output 1:

8-bit Binary Number => 11111111
Decimal Number = 255

Sample Output 2:

8-bit Binary Number => 10101010
Decimal Number = 170

Sample Output 3:

8-bit Binary Number => 101010102
Number entered is not a binary number

#include <iostream>
using namespace std;
int main()
{
int num;

[code]....

View 2 Replies View Related

C++ :: Representing A Rectangle With Only 3 Variables Instead Of 4

Apr 6, 2013

how to use 3 variables to represent a rectangle in a grid instead of using 4. The traditional way is to use (x,y) (x2,y2). I propose using (x,l,h).In the traditional way as you probably know, (x,y) is the left op most corner, and (x2,y2) is the bottom right most corner. In the way I am proposing X is the left side, l is the length of the top side, and also the length of the bottom. 'h' is the height of the left and right. I think it's obvious how these three can define a rectangle same as the four.

View 2 Replies View Related

C++ :: Convert Binary Number Into A Decimal Number

Jul 5, 2013

Here's the part of the codes where I tried to use boolean expression:

Code:
#include <iostream>
using namespace std;
int main() {
int num;
cout << "8-bit Binary Number=";
cin >> num;

[Code] .....

How can I get started with the body?

View 7 Replies View Related

C++ :: Convert Binary Number Into Decimal Number?

Jul 5, 2013

Here's the part of the codes where I tried to use boolean expression:

#include <iostream>
using namespace std;
int main()

[Code].....

May I know that how can I get started with the body?

View 5 Replies View Related

C/C++ :: Structure Representing Point In XY-plane

Mar 18, 2015

We are supposed to create a point structure that can be used to represent a point in the xy-plane. Then, write a menu-driven C++ program that uses variables of type point to perform a variety of tasks involving points in the xy plane, including slope, distance, midpoint, equation of a line passing through points, and colinearity. One of the functions we are to create is simply for reading in the user-input in the following form "(x,y)" with the user entering the parentheses and comma. We are to create two functions that translate back and forth between this format and what the assignment calls "one point variable."

I'm confused how I'm supposed to take the user entering, say "(1,4)" and reading that into an x and y, and then comparing it against another set of points. I'm guessing I read them in as a, b, c, d, but I'm not sure what this has to do with a structure.

View 1 Replies View Related

C++ :: Create A Class Representing Project Activities

Mar 24, 2013

Create a class representing project activities. In this class include all the required data members and member functions. Each activity should have a record of activity duration, calculated early start, early finish, late start, late finish, free float, and total float. Each activity may or may not maintain a list of its successors and predecessors. Provide your design in UML and implement it in C++ using an interface head file and an implementation source file. I do not understand classes or UML designs.

View 2 Replies View Related

C++ :: Read (three Digit) Integer Representing Value To Be Encrypted

Nov 3, 2013

I have been working on some C++ code that doesn't seem to be going right. I'm wanting it to read a (three-digit) integer representing the value to be encrypted, a (one-digit) integer representing the encryption key, encrypt the value and print the encrypted value. The encrypting method used is that each digit in the given number is replaced by ((the sum of that digit plus key) modulo 10) then the first and last “encrypted” digits are swapped.

For example, if the number entered was 216 and the key given was 7, after applying the encryption procedure described the first digit (2) would become 9, the middle digit (1) would become 8 and the last digit (6) would become 3. The first and last encrypted digits are then swapped. The program displays the encrypted number: that is 389 in this case.

#include <iostream>
using namespace std;
int main() {
int isolateDigits();
int replaceDigits();
int swapDigit1withDigit3();

[Code] ....

View 1 Replies View Related

C++ :: Count Number Of 0 In Binary Number

Apr 11, 2013

i am writing a program that accepts a decimal number from the user and convert it to binary numbers. After the conversion, i should count the number of 1's and 0's in the said binary number. I got upto converting and counting 1's using Brian Kernighan’s Algorithm. But, i can't seem to get it to count the number of 0's.

#include <iostream>
#include<bitset>
using namespace std;
int main() {
int num,count=0,Zero,count1 =0;
cout<<"Enter the number:";
cin>>num;
string binary;

[code].....

View 7 Replies View Related

C++ :: Print All 64-bit Binary Numbers

Jul 31, 2013

I have a program in c++ to print all the binary numbers that have 64 bits. But the problem is it works only for 30 bits. Beyond that the program does not work possibly because of insufficient space availability.

my code is as below:

// C++ program to generate n-bit binary numbers
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;

// This function generates all n bit Gray codes and prints the generated codes
void generateSequence(int n)

[Code] ....

View 2 Replies View Related

C/C++ :: How To Space Out Binary Numbers

Nov 13, 2014

I am having trouble finding out how to space out the binary numbers that I am displaying. Currently they are displaying all as one EX: 10001000

How can I get them to be space out properly like: 1000 1000?

Im guessing its something in my loop. Here's my function for converting to binary:

void DisplayBinary(int num) {
int ctr;
unsigned int mask = 32768;
printf("
The input number in binary is: ");
for (ctr = 1; ctr <= 16; ctr++) {

[Code] ....

View 4 Replies View Related

C :: Reading 16 Bit Binary Numbers From File

Mar 6, 2015

This is supposed to read a series of 16 bit binary numbers as short ints in the array memory. However, it only appears to be reading the first number.

Code:
short int memory[256];
void readFile(){
//read input file into int memory[]
FILE *ifp;
ifp = fopen("proj1a.dat", "r"); //input file

[Code] ....

View 9 Replies View Related

C :: Convert Binary Numbers To Decimal

Mar 27, 2013

The code should convert binary numbers to decimal but it doesn't..

Code:
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{

[Code] ....

View 4 Replies View Related

C++ :: Converting Binary Numbers Into Decimal

Apr 25, 2014

This is the question: [URL] .....

Now I have the binary numbers printed out in my code, but I don't know how I can covert them into to decimal.

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main() {
int numberOfDigits;
int numberOfRows;
char flag;

[Code] ....

View 1 Replies View Related

C/C++ :: Reading Binary Numbers From File?

Feb 9, 2014

I wanted to know if it is possible to read binary numbers(0's and 1's) from a file(text,picture, anything), and see them in the compiler.

View 14 Replies View Related

C++ :: Display Numbers In Binary Search Tree - Getting 0s

Jan 31, 2015

I want to display the numbers in a bst but all I get are 0s, what is wrong with my code that is causing this?

#include <iostream>
using namespace std;
class binarySearchTree {
private:
class TreeNode {
friend class binarySearchTree;
int value;

[Code] ....

View 1 Replies View Related

C/C++ :: Print Binary Numbers From 0 To M - Size N Bits

Apr 26, 2014

I need writing a program that print binary numbers from 0 to M.

Size N bits.

Ascending or descending order according to user choice.

When the default is M = 8, N = 3

View 5 Replies View Related

C :: Binary Number To Decimal

Mar 30, 2014

I am very new to programming and have been working on a program that can receive decimals or binary numbers and convert them. The decimal --> binary works fine. For some reason I cannot figure out I cannot get the "BinaryToDecimal" function to perform. By putting a "printf" into the for-loop.

Code:

#include <stdio.h>#include <string.h>
#include <math.h>
char* ReverseString (char _result[]) {
int start, end, length = strlen(_result);
char swap;
for (start = 0, end = length-1; start < end; start++, end--)

[code]....

View 2 Replies View Related

C++ :: How To Get Half Of The Last Binary Number

Nov 11, 2013

For example if we have 101010 First half is 101 which you get by multiplying 101010 * 10 ^-3

now how do you get the second half (010) ??

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved