Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is the problem I was given in class: 1. Given an array of input you are to

ID: 3620983 • Letter: H

Question

Here is the problem I was given in class:

1. Given an array of input you are to create an output array. Regardless of the number of times that an input value repeats (input values that occur more than one time in the input array) the output array should contain that value only once.

2. Consider uppercase and lowercase characters as the same value.

3. Count the number of times each value occurs in the input array.

4. Output will consist of the unique input values (represented as a lowercase character) and the number of times that each unique input value is repeated in the input array.

5. Print each element of the output array followed by a tab, and then the number of times that value occurred in the input array on one line. Print your output to the screen.

6. your solution must use the following function:

void newArray(char inputArray[], char outputArray[], int& numberOfUniqueValues, int size);

use of any other functions is up to you.

7. the program should run only one time.

===================================================================================

example, the input array:

She sells seashells.

should produce the following output:


s     6
h     2
e     4
l     4
a     1
2
.       1

List of inputs

uncopyrightable
Every man loves some woman.
1 + 1 = 2

My Issue

My teacher never really showed us how to do something like this. I know how to make loops with arrays, but I was never taught to take unique value counts, which is where true problem lies.

My code so far

#include
#include
using namespace std;

void newArray(char inputArray[], char outputArray[], int& numberOfUniqueValues, int size);

int main()
{
    char inputArray[]="uncopyrightable "
    "Every man loves some woman. "
    "1 + 1 = 2 ";
    char outputArray[0];
    int numberOfUniqueValues = 0, size = 0;

    newArray(inputArray,outputArray, numberOfUniqueValues, size);
   
    system("pause");
    return EXIT_SUCCESS;
}


void newArray(char inputArray[], char outputArray[], int& numberOfUniqueValues, int size)
{
     while (inputArray[size])
    {
       outputArray[size]=inputArray[size];
       size++;
    }
  
    while (outputArray[size])
    {
        cout << outputArray << " " << numberOfUniqueValues << endl;
        size++;
    }
}

Explanation / Answer

please rate - thanks

because of this

7. the program should run only one time.

I made the input entered by the user

message me if any problems

#include <iostream>
#include <cstring>
using namespace std;
void newArray(char inputArray[], char outputArray[], int& numberOfUniqueValues, int size);
void output(char inputArray[], char outputArray[], int numberOfUniqueValues, int size);
int main()
{    char inputArray[80];   //=//"uncopyrightable ";
   // "Every man loves some woman. ";
   // "1 + 1 = 2 ";
      //"She sells seashells. ";
    char outputArray[50];
    int numberOfUniqueValues = 0, size = 0;
    cout<<"Enter a string(ctrl^Z to exit): ";
    cin.getline(inputArray,80);
    while(cin)
    {numberOfUniqueValues = 0;
     size = 0;
    for(size=0;inputArray[size]!='';size++);
    newArray(inputArray,outputArray, numberOfUniqueValues, size);
    cout<<" "<<inputArray<<" ";
    output(inputArray,outputArray, numberOfUniqueValues, size);
    cout<<"Enter a string(ctrl^Z to exit): ";
    cin.getline(inputArray,80);
}
    return EXIT_SUCCESS;
}
void output(char inputArray[], char outputArray[], int numberOfUniqueValues, int size)
{int i,j,count;
cout<<"char count ";
for(i=0;i<numberOfUniqueValues;i++)
   {count=0;
   for(j=0;j<size;j++)
       if(tolower(inputArray[j])==outputArray[i])
            count++;
   cout<<outputArray[i]<<" "<<count<<endl;
}
}
void newArray(char inputArray[], char outputArray[], int& numberOfUniqueValues, int size)
{int i,j;
bool found;
for(i=0;i<size;i++)
   {found=false;
    for(j=0;j<numberOfUniqueValues;j++)
        if(tolower(inputArray[i])==outputArray[j])
             {found=true;
             j=numberOfUniqueValues+2;
             }
    if(!found)
        {outputArray[numberOfUniqueValues]=tolower(inputArray[i]);
         numberOfUniqueValues++;     
         }
    }
numberOfUniqueValues--;   
}