Question

In: Computer Science

( Posting the same question for third time. Can I please get answer in C++.( and...

( Posting the same question for third time. Can I please get answer in C++.( and not in C or Java) ..... Please Try and Provide me a complete programm Answer. not just one or two function)

* Declare a single dimensional array of 65 characters. Convert each character into an integer and store it in a linked list. Manipulate the linked list by completing the following task:

Create an additional linked list call greater_List, using the original linked list copy all number greater than 100 into the greater_list and give a total count of the numbers greater than 100. Create an additional array called less_array, copy all the numbers less than or equal to 100 in the original list into less_array give a total count of the numbers that are less than or equal to 100.

Solutions

Expert Solution

#include <iostream>
using namespace std;

#define MAX 65
#define BREAK_VAL 100

/*linked list node*/
struct node
{
   node(int const& val) : value (val), next(nullptr)
   {
   }
  
   int value;
   node* next;
};

/*print integer array*/
void PrintArr(int arr[], int const& size)
{
   cout << "Printing Array" << endl;
   for(int i = 0; i< size; ++i)
   {
       cout << arr[i] << " ";
   }
   cout << endl;
}


/*print linked list*/
void PrintList(node* head)
{
   cout << "Printing list" << endl;
   while(head)
   {
       cout << head->value << " ";
       head = head->next;
   }
   cout << endl;
}

/*make linked list from array*/
node* MakeLL(char arr[], int const &size)
{
   if(size <= 0)
   {
       return nullptr;
   }
  
   node *head = new node(arr[0]);
   node* curr = head;
   int i = 1;
   for(; i<size; ++i)
   {
       curr->next = new node(arr[i]);
       curr = curr->next;
   }
   return head;
}

/*fill greater values than comp_value in linked_list*/
void MakeGreater(node *head, node *&greater_list_head, int &count_greater, int const& comp_value)
{
   node* curr = greater_list_head;
   count_greater = 0;
  
   while(head)
   {
       if(head->value > comp_value)
       {
           ++count_greater;
           if(!greater_list_head)
           {
               greater_list_head = new node(head->value);
               curr = greater_list_head;
           }
           else
           {
               curr->next = new node(head->value);
               curr = curr->next;
           }
       }
       head = head->next;
   }
}

/*fill lesser values then comp_value in array*/
void FillLesser(node* head, int arr[], int &count_lesser, int const& comp_value)
{
   count_lesser = 0;
   while(head)
   {
       if(head->value <= comp_value)
       {
           arr[count_lesser++] = head->value;
          
       }
       head = head->next;
   }
}

int main()
{
   /*user input for MAX characters*/
   char arr[MAX];
   int i = 0;
   while(i < MAX)
   {
       cin >> arr[i];
       ++i;
   }
  
   /*Making Linked list from user character array*/
   node *head = MakeLL(arr, MAX);
  
   /*finding all elements greater than BREAK_VAL and making new linked list*/
   node *greater_list = nullptr;
   int count_greater = 0;
   MakeGreater(head, greater_list, count_greater, BREAK_VAL);
  
   /*finding all elements lesser than BREAK_VAL and making new array*/
   int arr_lesser[MAX-count_greater];
   int count_lesser;
   FillLesser(head, arr_lesser, count_lesser, BREAK_VAL);
  
   /*Printing greater_list*/
   PrintList(greater_list);
  
   /*Printing arr_lesser*/
   PrintArr(arr_lesser, count_lesser);
  
   cout << "Total numbers of chars whose values are less than 100 : " << count_lesser << endl;
   cout << "Total numbers of chars whose values are greater than 100 : " << count_greater << endl;
}


Related Solutions

I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I am m designing a questionnaire for the topic: FACTORS INFLUENCING CONSUMER BUYING BEHAVIOR IN PURCHASE OF MILK IN ORGANIZED AND UNORGANIZED SECTOR. the study is basically to study the factors that influence consumer decisions in purchase of milk in organized and unorganized sector of milk. For this i need variables that influence purchase of milk in organized and unorganized sector. \ Note: I need...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I am m designing a questionnaire for the topic: FACTORS INFLUENCING CONSUMER BUYING BEHAVIOR IN PURCHASE OF MILK IN ORGANIZED AND UNORGANIZED SECTOR. the study is basically to study the factors that influence consumer decisions in purchase of milk in organized and unorganized sector of milk. For this i need variables that influence purchase of milk in organized and unorganized sector. Note: I need just...
PLEASE THIS IS THE THIRD TIME I AM POSTING THIS QUESTION I WANT A COMPLET WORK...
PLEASE THIS IS THE THIRD TIME I AM POSTING THIS QUESTION I WANT A COMPLET WORK SO I CAN GET GOOD GRADES analyze at least three different marketing examples that will help inform marketing plan. 1 What product or service is being marketed 2 What media each uses for marketing the service? 3 How effective the marketing is for you the potential consumer (support why with specifics)? 4 Why is each company marketing and why did they choose the style...
THIS IS THE THIRD TIME POSTING IT!!! CAN SOMEONE ANSWER THIS AND TYPE THE RESPONSE. THANK...
THIS IS THE THIRD TIME POSTING IT!!! CAN SOMEONE ANSWER THIS AND TYPE THE RESPONSE. THANK YOU! What are one example of a monopolistically competitive firm, oligopoly, and monopoly in your local area? In your example, please relate to the market characteristics of each of the market structures? Work cite and type is a most!!!!!
This is my second time posting this question. Can the answer be typed please? Its hard...
This is my second time posting this question. Can the answer be typed please? Its hard to read someones handwritten cursive response. In recent years, many elderly people have purchased Medigap insurance policies to cover a growing Medicare copayment. These policies cover some or all of the medical costs not covered by Medicare. Use economic theory to explain how the growth of these policies is likely to influence the demand for health care by elderly people.
( I am posting this for the third time. The first time I posted, whoever did...
( I am posting this for the third time. The first time I posted, whoever did it, he did not read the instruction and did not mention the letters with the answer, such as which one is A, B, C, D, E, F, while he was answering. The 2nd time I posted, whoever did it, he had handwritten it. So, I faced difficulty to understand the handwriting. The handwriting was horrible. Please mention the letters with the answers this time...
Please, this is the fifth time I am posting this question, all the answers I am...
Please, this is the fifth time I am posting this question, all the answers I am getting are inaccurate because the experts are not putting all value into account like the loan interest rate, tax rate, depreciation, annual cash outflows, salvage value, annual cash inflows, and discount rate. please also support the answer with a full interpretation and the step by step approach in solving the answer. thank you:) In this paper, please discuss the following case study. In doing...
Can I please get an in-depth answer to this question: You are an Audit Senior currently...
Can I please get an in-depth answer to this question: You are an Audit Senior currently planning the 30 June 20X9 audits of Comp Limited (Comp), Health Limited (Health), and News Limited (News). At recently scheduled planning meetings with Comp, Health and News, you obtain the following overview of this year’s operations for each of the three client companies: Comp is a manufacturer of computer hardware. The old costing system that was developed inhouse, could no longer keep up with...
Hi. Please could I get a complete answer to the question below using c++ and codeblocks...
Hi. Please could I get a complete answer to the question below using c++ and codeblocks Add a recursive member function to bSearchTreeType that returns the depth of a given node whose info member contains a specific value, and returns -1 if the node is not in the tree. For example, tree in figure 11-8 on page 622 of Malik,z the depth of 40 is 4, the depth of node 50 is 1 etc. Use the following header:    template<class...
Please Answer Promptly:- How long does it take normally to get a question answered after posting?...
Please Answer Promptly:- How long does it take normally to get a question answered after posting? The EIA reports the composite refinery acquisition price in the Rocky Mountain region ( PADD 4) for a barrel of crude oil during April 2019 was $59.24. During the same period of time, the composite refinery acquisition price for the East Coast (PADD 1) was $70.01. During the same period, the average wholesale price of a gallon of gasoline (average of all grades, all...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT