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
6
Novosadov [1.4K]

Answer:

government and New Zealand

Explanation:

you can see the web site name the name is gov.nz ,gov mens- government and nz means new Zealand

thank you like us

8 0
2 years ago
Read 2 more answers
There are six different sequences for the three approval tasks: check inventory; check credit; check special terms.
Lana71 [14]

Answer:

i dont know i am 13

Explanation:

3 0
3 years ago
Preliminaries
Ratling [72]

Answer:

okahsb

Explanation:

8 0
3 years ago
How does the technology affect you daily living? Give situations where you use technology and how it helped you.​
Fiesta28 [93]

Answer:

Great!

Explanation:

I use mobile phone and i use it as exmergency phone

5 0
3 years ago
When does personal information often need to be entered online?
soldi70 [24.7K]

Answer:

Like when your doing an application for a job or anything important lol

Explanation:

3 0
3 years ago
Other questions:
  • 4. When you're working with a word processing document and you press the Del key, what happens?
    8·2 answers
  • The largest group of Linux users is likely to be
    7·1 answer
  • Give me give me keyboard on this phone please provide nice I can't type where is the keyboard.Give me give me keyboard on this p
    6·2 answers
  • Select all that apply.
    8·2 answers
  • In cell F15, insert a function that will automatically display the word Discontinue if the value in cell D15 is less than 1500,
    6·1 answer
  • A typical analog cell phone has a frequency of 850 mhz; a digital phone a frequency of 1950 mhz. compared to the signal from an
    7·1 answer
  • Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for the value to conv
    13·1 answer
  • / Looks up author of selected books
    15·1 answer
  • Which of the following statements about interpreting colors are true? Select 3 options.
    11·1 answer
  • What can be used to help diagnose and fix computer hardware problems?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!