1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Xelga [282]
3 years ago
9

p3_unzip :: [(a,b)] -> ([a], [b]) Write a function that takes a list of two-tuples and returns a tuple of two lists -- the fi

rst containing the first element of each tuple, and the second the second element (i.e., the reverse of "zip"). Examples: > p3_unzip [('a',1),('b',5),('c',8)] ("abc",[1,5,8])
Computers and Technology
1 answer:
klio [65]3 years ago
4 0

Answer:

<em>C++.</em>

Explanation:

#include <iostream>

#include<tuple>

using namespace std;

////////////////////////////////////////////////////////////

tuple<char*, int*> p3_unzip(tuple<char, int>* list, int count) {

   char* list1 = new char[count];

   int* list2 = new int[count];

   

   for (int i=0; i<count; i++) {

       tuple<char, int> temp = list[i];

       list1[i] = get<0>(temp);

       list2[i] = get<1>(temp);

   }

   

   tuple<char*, int*> new_tuple;

   get<0>(new_tuple) = list1;

   get<1>(new_tuple) = list2;

   

   return new_tuple;

}

int main() {

   tuple<char, int>* list;

   int count = 0;

   ////////////////////////////////////////

   cout<<"How many tuples? ";

   cin>>count;

   list = new tuple<char, int>[count];

   cout<<endl;

   

   char a;

   int b;

   tuple<char, int> temp;

   for (int i=0; i<count; i++) {

       cout<<"tuple "<<i+1<<" char: ";

       cin>>a;

       get<0>(temp) = a;

       

       cout<<"tuple "<<i+1<<" int: ";

       cin>>b;

       get<1>(temp) = b;

       

       list[i] = temp;

       cout<<endl;

   }

   ////////////////////////////////////////

   tuple<char*, int*> new_tuple = p3_unzip(list, count);

   char* list1 =  get<0>(new_tuple);

   int* list2 = get<1>(new_tuple);

   

   cout<<"Returned tuple:([";

   for (int i=0; i<count-1; i++) {

       cout<<list1[i]<<", ";

   }

   

   cout<<list1[count-1]<<"],[";

   

   for (int i=0; i<count-1; i++) {

       cout<<list2[i]<<", ";

   }

   

   cout<<list2[count-1]<<"])";

   ////////////////////////////////////////

   delete[] list, list1, list2;

   return 0;

}

You might be interested in
Tina reported a safety hazard at her workplace to OSHA. Representatives from OSHA
Anna11 [10]

Answer:

The correct answer is: <em>Protection from Workplace Retaliation</em>

Explanation:

Protection from Workplace Retaliation is one of the 20 Whistleblower Laws enforced by OSHA. According to the Protection from Workplace Retaliation (PFWR) law, employers cannot treat employees unfairly in retaliation to employees reporting  workplace safety hazards to OSHA. The PFWR states that employers cannot retaliate by: denying employees leave, demoting them, firing them, reducing work hours, or denying them promotions.

In this case, Tina's employer violated the Protection from Workplace Retaliation law by giving her menial and difficult jobs in response to her reporting a safety hazard to OSHA.

8 0
3 years ago
Which of the following statements best describes how digital photographs can be used?
kipiarov [429]

Answer:

umm wheres the options so we can answer it and ty

Explanation:

3 0
3 years ago
Read 2 more answers
What would happen if technology no longer existed? How would it change education? Select three options.
PSYCHO15rus [73]

Answer:

answer 4

Explanation:

no technology, no computers, no computers= paper and paper= handwriting :-)

6 0
1 year ago
5. Write few lines of code that creates two arrays with malloc. Then write a statement that can create a memory leak. Discuss wh
Darina [25.2K]

Answer:

 // function with memory leak  

void func_to_show_mem_leak()  {  

int *pointer;

pointer = malloc(10 * sizeof(int));

*(pointer+3) = 99;}  

 

// driver code  

int main()  

{  

    // Call the function  

   // to get the memory leak  

   func_to_show_mem_leak();  

     return 0;  }

Explanation:

Memory leakage occurs when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[] operator. One of the most memory leakage occurs by using wrong delete operator. The delete operator should be used to free a single allocated memory space, whereas the delete [] operator should be used to free an array of data values.

3 0
2 years ago
A startup is developing a new web browser with a focus on accessibility for visually impaired users. The startup founder is cons
gavmur [86]

Answer:

A license that allows developers to change and share the source

code of the licensed software

Explanation:

i learned this, btw brainly stop removing my answers

7 0
2 years ago
Other questions:
  • Switches: Select one:
    5·1 answer
  • The measure of the maximum amount of data that can travel through a computer’s communications path in a given amount of time is
    9·1 answer
  • An ______ search is when the buyer looks for information beyond personal knowledge to help make the buying decision, such as che
    10·1 answer
  • A ________ is a virus that is triggered on a certain date.
    11·1 answer
  • How to do this PLEASE HELP 80 points!
    15·1 answer
  • Which of the following is true about driving on "bald" tires?
    5·1 answer
  • Such a class might store information about the account balance, the name of the account holder, and an account number. What inst
    13·1 answer
  • A profit of ₹ 1581 is to be divided amongst three partner P,Q and R in ratio 1/3:1/2:1/5.theshareof R will be?​
    10·1 answer
  • What report provides data on how specific sections of a website performed?
    6·1 answer
  • Write a program that prompts the user for two numbers then outputs the result of dividing the first number by the second number
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!