Другие языки программирования и технологии
помогите с C++
в общем такая штука, мне нужно написать функцию для рэндомного создания 3-ёх массивов. Предположим у меня есть 3 различчных массива A, B и С трёх размерностей - A[5] B[6] C[10]. Надо напистаь функцию, которая создаёт эти случайные массивы, проблема в том, что у всех разные размерности, и когда я создаю функцию, пишу например void CreateMassiv(int ???) и тут заместо знаков вопроса я не знаю как поставить, если бы был один массив с одной размерностью, например A[6] то я бы сделал так void CreateMassiv(int Massiv[6]) а как сделать в моей ситуации??
блиин. . цикл до 10... и забивай значения рендомно во все массивы.. . в А и В лишние не запишутся.... заранее А и В объяви как массивы A[5] b[6]
#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
int * random_array(int *, const size_t);
void show_array(int *, const size_t);
int main() {
size_t size_1 = 5, size_2 = 6, size_3 = 10;
int * a, * b, * c;
a = b = c = NULL;
srand(unsigned(time(NULL)));
a = random_array(a, size_1);
b = random_array(b, size_2);
c = random_array(c, size_3);
show_array(a, size_1);
show_array(b, size_2);
show_array(c, size_3);
delete[] a, b, c;
a = b = c = NULL;
cin.get();
return 0;
}
void show_array(int * _array, const size_t _size) {
size_t n = _size;
while (n--) cout << setw(7) << *_array++;
cout << endl;
}
int * random_array(int * _array, const size_t _size) {
_array = new int [_size];
int * ptr = _array;
size_t n = _size;
while (n--) *ptr++ = rand();
return _array;
}
#include <iomanip>
#include <ctime>
using namespace std;
int * random_array(int *, const size_t);
void show_array(int *, const size_t);
int main() {
size_t size_1 = 5, size_2 = 6, size_3 = 10;
int * a, * b, * c;
a = b = c = NULL;
srand(unsigned(time(NULL)));
a = random_array(a, size_1);
b = random_array(b, size_2);
c = random_array(c, size_3);
show_array(a, size_1);
show_array(b, size_2);
show_array(c, size_3);
delete[] a, b, c;
a = b = c = NULL;
cin.get();
return 0;
}
void show_array(int * _array, const size_t _size) {
size_t n = _size;
while (n--) cout << setw(7) << *_array++;
cout << endl;
}
int * random_array(int * _array, const size_t _size) {
_array = new int [_size];
int * ptr = _array;
size_t n = _size;
while (n--) *ptr++ = rand();
return _array;
}
int *CreateArray(int size)
{
int *A=new int[size];//не?
for(int i=0;i < size; i++)A[ i ]=rand()0;
return A;
}
...
int *C;
C=CreateArray(10);
....
delete[] C;
{
int *A=new int[size];//не?
for(int i=0;i < size; i++)A[ i ]=rand()0;
return A;
}
...
int *C;
C=CreateArray(10);
....
delete[] C;
#include <iostream>
#include<time.h>
using namespace std;
int CreateMassiv(int*& p)
{
int j,r=1+rand() % 10;
p=new int[r];
for(j=0;j-r;p[j++]=rand());
return r;
}
int main ()
{
int j,A,B,C;
int *a,*b,*c;
srand(time(NULL));
A=CreateMassiv(a); for(j=0;j-A;cout << a[j++] << '\t'); cout << endl;
B=CreateMassiv(b); for(j=0;j-B;cout << b[j++] << '\t'); cout << endl;
C=CreateMassiv(c); for(j=0;j-C;cout << c[j++] << '\t'); cout << endl;
delete [] a,b,c;
}
#include<time.h>
using namespace std;
int CreateMassiv(int*& p)
{
int j,r=1+rand() % 10;
p=new int[r];
for(j=0;j-r;p[j++]=rand());
return r;
}
int main ()
{
int j,A,B,C;
int *a,*b,*c;
srand(time(NULL));
A=CreateMassiv(a); for(j=0;j-A;cout << a[j++] << '\t'); cout << endl;
B=CreateMassiv(b); for(j=0;j-B;cout << b[j++] << '\t'); cout << endl;
C=CreateMassiv(c); for(j=0;j-C;cout << c[j++] << '\t'); cout << endl;
delete [] a,b,c;
}
К каждому по отдельности прописать.
Похожие вопросы
- Помогите срочно C#
- Люди, помогите скачать C++!!
- помогите, пожалуйста, c делфи!
- помогите с C програм не выводит результаты
- Помогите Диск C сам заполняеться вот например выйду и диска памать 6гб опять зайду уже 5.65гб и вотак до 1гб помогите
- помогите массив c#.
- Помогите по C#
- Помогите с C++
- Помогите с C++
- Помогите пожалуйста. C#