I need help on arrays

I need a specific program that asks the user what size of an array will be put out and it limits to 1x1 up to 10x10 array
and after that you have to enter a number from 1-10 that will pop out from the first array then asks another to put up the second and up to 10 and when type 0 the program exits

Output:
Enter a number to create a multidimensional array: 5
Now creating an array 5x5
You are allowed to enter 1-10 only or numbers that are existing in the array
You will exit the program when you press 0
Enter a number: 1
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

Thanks in advance ( ͡° ͜ʖ ͡°)VxK

We won't write your programm for you
This is not hard to do so you should do it yourself
why not make one if it is not hard. I would not been trubled in creating anew account if it is not that difficult. Is it wrong to be new here??
int rows = 0;
int cols = 0;
printf ("Enter #of rows: ");
scanf ("%d",&rows);
printf ("Enter #of columns: ");
scanf ("%d",&cols);

int **array = new int*[rows];
for(int i = 0; i < rows; i++)
array[i] = new int[cols];


see if you can do the rest.. you can use memcopy to fill in the zeros
then you need to clean up with 2 Deletes


I will be back if you need help
Last edited on
why not make one if it is not hard.
Because you wouldn't learn anything from it

I would not been trubled in creating anew account if it is not that difficult.
Look, we are here to help you learn, not to do the stuff for you

Is it wrong to be new here??
No, but when you're new you should be on the "beginners" section and you should read how this forum works and how to ask a question properly.
http://www.cplusplus.com/forum/beginner/1/

cplusplus wrote:
Don't post homework questions
Programmers are good at spotting homework questions; most of us have done them ourselves. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions.


I will not do the task for you but I will help you if you run into problems you can't solve yourself.
Last edited on
try this :

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
#include <iostream>
#include <string>
#include <vector>

int main()
{

	int ** array;
	unsigned int rows = 0;
	unsigned int cols = 0;

	std::cout << "Number of row : " << std::endl;
	std::cin >> rows;
	std::cout << "Number of column : " << std::endl;
	std::cin >> cols;

	array = new int * [rows];
	int i = 0;
	for(; i < rows ; ++ i)
		array[i] = new int [cols];

	std::vector<int> temp;

	int key = -1;
	int counter = 0;
	int max_count = rows * cols;
	do
	{
		std::cin >> key;
		if(key == 0)
			break;
		temp.push_back(key);
		++ counter;
	} while(counter != max_count);

	
	int index = 0;
	for(int c = 0;c < cols;++c)
	{
		for(int r = 0;r<rows;++r)
		{
			array[r][c] = temp[index ++];
			std::cout << array[r][c];
		}
		std::cout << std::endl;
	}
	delete[] array;
	
	system("pause");
	return 0;
}
Topic archived. No new replies allowed.