I have a 2D character array like this: [ [1 D E F G H]
[2 C E]
[3 A C]
[4 H I J]
[5 A B D]]
How do you make a character array consisting of distinct alphabets?
That is the output should be [A B C D E F G H I J].
I need a C++ code for the same.
Here is the solution to above problem. Please refer to code
screenshot for indentation help and read code comments for more
help.
I am using c++ map to make sure the characters are unique similarly you can use another character array
char C[] to mark all the unique characters just like the map
C++ Code
#include<iostream>
#include<string.h>
#include<map>
using namespace std;
int main()
{
//using map to store only unique characters
map<char,bool> M;
//making the array
char A[][5]={{'D','E','F','G','H'},{' ','
','C','E'},{' ',' ','A','C'},{' ','H','I','J'},{'
','A','B','D'}};
//traversing the array
for(int i=0;i<5;++i)
{
for(int j=0;j<5;++j)
{
if(A[i][j]!='
'&& A[i][j]!='\0')
M[A[i][j]]=true;
}
}
char B[100];
int j=0;
//storing unique value in new array
for(auto i=M.begin();i!=M.end();++i)
{
B[j++]= i->first;
}
//compting string length
int length= strlen(B);
//displaying the new array
for(int i=0;i<length-1;++i)
{
cout<<B[i]<<" ";
}
return 0;
}
OUTPUT OF THE CODE

SCREENSHOT OF THE CODE

A chromosome with genetic markers A, B, C, D, E, F, G, H, I and J ( “*” represents the centromere ) is shown below: A B C D E * F G H I J Another chromosome is found to contain a b c d i h g f * e j If these two chromosomes are paired during meiosis, a single crossover takes place between F and G, and another single crossover takes place between H and I....
- A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Telecommuting - A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Change - A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Job Sharing - A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. Job Redesign - A. B. C. D. E. F. G. H. I. ...
C++ program 2D array of intergers Initialize the 2-D array of integers detailed below. { 25, 50, 75, 100, 125 }, { 50, 100, 150, 200, 250}, { 75, 150, 225, 300, 375}, { 100, 200, 300, 400, 500}, { 125, 250, 375, 500, 625 }, Traverse and output array elements for the 2D array above in reverse order. Starting with 625, 500, 375, 250, etc…. Attach Snipping Photo of Source Code and Output below. Directly Access and output 225...
Write a Java method that searches a 2-d array for a specific character. Return the index of the first location of the character. Method header: public static void play(char c, char[][]wordSearch){ Example: a e v s l g r e d k h k q s e z j c p o a t s o v a n m n l q p f o x b The character 's' appears at index 0,3.
How to replace elements in a 2D array? Okay so for my program, I am trying to create a fish tank. My program is to generate 4 different FISH: ><))'> in a tank of tilde (~) characters. The tank is a 2D array of 8 rows and 32 columns so it would look like ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for one of the eight rows (before I generate the random positions of the fish in the rank). Then one row could look like ~~~~~~~~~~><))'>~~~~~~~~~~~~~~~~...
4. R(A, B, C, D, E, F, G, H, I, J) where A → B, C, D BE F→ G, H, I (A, F) → B, C, D, E, G, H, I, J For each of the following relations, normalize it into a set of BCNF relations.
Design the optimal (Huffman) code for the alphabet {a, b, c,
d, e, f, g, h, i, j, k, l}, where frequencies are given in the
table below:
Draw the appropriate decoding tree.
a 0.25 g 0.02 b 0.01 h 0.12 c 0.09 i 0.15 d 0.02 j 0.04 e 0.24 k 0.01 f 0.04 l 0.01
What is the output of the following code:for(int i = 1; i < 5; i++) { cout << i << " "; for(int j = 1; j <= i; j++) { cout << j << " "; } cout << endl; } Write C++ code that will store the input “John” in a character array. Make sure to use an array initializer. //CODE int g(int a, int b); void g(int a, int b); True or False? Function g above...
We have the symbols A, B, C, D, E, F, G, H with frequencies 1, 1, 2, 4, 8, 16, 32, 64. Show the Huffman tree and Huffman code for the symbols. How much compression does a 1000 digit file use when using this Huffman code based on an 8-bit ASCII code (ie, ISO 8859-1)?
There are 10 letters - a, b, c, d, e, f, g, h, n, g. I have to arrange them in a way that "a" wouldn't be near "c" and also "a" wouldn't be near "g" How many possible combinations are possible? How to solve it mathematically?