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]
4 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]4 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
Which can be used to enter and manipulate information in a database?<br><br> ANSWER: C) a form
alexgriva [62]

Answer:

a form

Explanation:

it says the answer already in the question

3 0
4 years ago
One disadvantage of online information sharing is that:
zubka84 [21]

Answer:

its b i just took the test

Explanation:

3 0
3 years ago
Read 2 more answers
Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which princ
kaheart [24]

Answer:

Sequencing

Explanation:

I have taken the test

5 0
3 years ago
Frrrrrrrrrrreeeeeeeeee brainliest for u
sukhopar [10]

Answer:

Yay I want brainliest

Explanation:

5 0
3 years ago
Read 2 more answers
Which of these devices can completely stop broadcasts from being passed on across the network? routerswitchaccess ponthub
cestrela7 [59]

Answer

An Access point can completely stop broadcasts from being passed on across the network.

Explanation.

An Access point is a hardware type that is part of local area network which has capability of allowing wireless communication from devices through a wireless stand,which connects in between devices and the network. A good example of these devices are routers that allows wireless devices to connect to a wireless network.So when it is passed on across a network an Access point can completely stop.

8 0
3 years ago
Read 2 more answers
Other questions:
  • You’re responsible for an always-on VPN connection for your company and have been told that it must utilize the most secure mode
    12·1 answer
  • .exe, .msi, .msp, .inf - together, what do these filetypes indicate
    12·2 answers
  • Complete the statement below with the correct term.
    5·1 answer
  • What is the biggest difference between single system recording and double system recording?
    8·1 answer
  • Spoken word and written word are different because what
    9·1 answer
  • Explain the difference between good and bad table structures. How do you recognize the difference between good and bad structure
    14·1 answer
  • What does the doppler effect do?
    9·1 answer
  • Match the command to the use. Test connectivity to a remote computer Test DNS lookup View packets in a transmission Display the
    14·1 answer
  • Jettison folk 2007, Magnum opus, be moving, offers poisoned commentary on the film industry.
    7·1 answer
  • Brainliest For Tascake Because People Texted Before Tascake Could<br><br> Hurry Tascake
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!