Answer the question
In order to leave comments, you need to log in
Why are numbers not in the specified range written to the array?
I wrote the code, the elements of the array must be set randomly in the specified range, but when the array is displayed, the numbers are random.
#include<iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
void inputArray(int *p, int k); // Функция инициализации массива
void printArray(int B[14][24], int i, int j) { // Функция для вывода массива
for (i = 0; i < 24; i++) {
for (j = 0; j < 14; j++) {
cout<<setw(5)<<B[i][j];
}
cout<<endl;
}
}
void processingArray(int *B[0], int k, int i, int j) { // Функция для обработки массива
for (i = 0; i < 24; i++) {
for (j = 0; j < k; j++) {
if (B[i][j] > 0) {
B[i][j] = 0;
}
else {
B[i][j] = B[i][j] * -10;
}
}
};
}
int main() {
setlocale(LC_ALL, "Russian");
const int n = 14;
const int m = 24;
int B[n][m], i=0, j=0;
for(i = 0; i < n; i++){
inputArray(B[i], m);
for (j = 0; j < m; j++){
cout<<setw(12)<<B[i][j];
}
cout<<endl;
}
cout<<endl<<endl;
}
void inputArray(int *p, int k) {
srand(time(0));
*p = (rand( )%100 - 50);
for (int i = 1; i < k; i++) {
*(p + i) = -i * * (p + i - 1);
}
}
Answer the question
In order to leave comments, you need to log in
*p = (rand( )%100 - 50);
for (int i = 1; i < k; i++) {
*(p + 1) = -i * * (p + i - 1);
}
*(p+X)
p[X]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question