M
Mario Contreras
From: "Mario Contreras" <[email protected]>
Subject: Re: Concatenate
Date: Friday, July 04, 2003 2:53 PM
This is what I have, but it needs a little modification
It gets all values from 2 arrays, but still not perfect..
// I need to put 2 arrays together in an
// single int array.
// no duplicates
#include <iostream>
using namespace std;
#define L2 << endl << endl
#define L3 << endl << endl << endl << endl
class Set{
public:
void Sum(int a[], int b[], int c[], int size);
}; // End of class
// i Corre a
void Set::Sum(int a[], int b[], int c[], int size){
int tmp = size;
for (int i = 0; i < size; i++){
c = a;
}
// Jota corre b
for (int j = 0; j < size; j++){
for (int k = 0; k < size; k++){
if(c[k] != b[j])
c[j+tmp] = b[j];
}
}
// Just to print all c array
for (int z = 0; c[z] != '\0'; z++)
cout << "c[" << z << "] = " << c[z] << endl;
}
void main(){
int size = 4;
int a[] = {1,2,3,4};
int b[] = {1,3,5,7};
int c[32] = {0};
Set s;
s.Sum(a, b, c, size);
}
Subject: Re: Concatenate
Date: Friday, July 04, 2003 2:53 PM
This is what I have, but it needs a little modification
It gets all values from 2 arrays, but still not perfect..
// I need to put 2 arrays together in an
// single int array.
// no duplicates
#include <iostream>
using namespace std;
#define L2 << endl << endl
#define L3 << endl << endl << endl << endl
class Set{
public:
void Sum(int a[], int b[], int c[], int size);
}; // End of class
// i Corre a
void Set::Sum(int a[], int b[], int c[], int size){
int tmp = size;
for (int i = 0; i < size; i++){
c = a;
}
// Jota corre b
for (int j = 0; j < size; j++){
for (int k = 0; k < size; k++){
if(c[k] != b[j])
c[j+tmp] = b[j];
}
}
// Just to print all c array
for (int z = 0; c[z] != '\0'; z++)
cout << "c[" << z << "] = " << c[z] << endl;
}
void main(){
int size = 4;
int a[] = {1,2,3,4};
int b[] = {1,3,5,7};
int c[32] = {0};
Set s;
s.Sum(a, b, c, size);
}