1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <stdio.h>
using namespace std;
int
main ()
{
//T is the number of continents
//each continent has a number of A-B populations (for example A-B (continent 1), A2-B2 (continent 2)
int T = 0;
cout << "How many continents are there on your planet?" << endl;
cin >> T;
cout << "You have input " << T << " continents" << endl << endl;
//these arrys will hold the masses of A animals on each continent
//for example A[0] and array of masses of animals on the first continents
int *A[T];
int *B[T];
//number of animals in each population (on each continent - a counter)
int A_n[T];
int B_n[T];
int pairsCount[T];
int pairs = 0;
//cin the information
for (int i = 0; i < T; i++)
{
cout << "Let's talk about the " << T << " population" << endl;
cout << "How many animals are there? " << endl;
cout << "The number of A animals on the " << i + 1 << " continent " << endl;
cin >> A_n[i];
cout << "Please write the masses of the A animals" << endl;
int a_sub[A_n[i]];
for (int a = 0; a < A_n[i]; a++)
{
cin >> a_sub[a];
}
cout << "The number of B animals on the " << i + 1 << " continent " << endl;
cin >> B_n[i];
cout << "Please write the masses of the B animals" << endl;
int b_sub[B_n[i]];
for (int a = 0; a < B_n[i]; a++)
{
cin >> b_sub[a];
}
//trying to store the pointers here in the corresponding arrays
//the idea is to put the array with masses into a bigger array
A[i] = &a_sub[0];
B[i] = &b_sub[0];
//breakpoint 1
cout << A[0][0];
cout << A[0][1];
cout << A[0][2] << endl;
}
//breakpoint 2
cout << A[0][0];
cout << A[0][1];
cout << A[0][2];
}
|