Open hayksargsyan1212 opened 2 months ago
void h(int array[]) { int d = array[0]; for (int i = 1; i < 10; i++) { if (d < array[i]) { d = array[i]; } } std::cout << "max is " << d << std::endl; }
void ywq(int array[]) { int q = array[0]; for (int i = 1; i < 10; i++) { if (q > array[i]) { q = array[i]; } } std::cout << "min is " << q << std::endl; }
int main() { const int SIZE = 10; int array[SIZE];
std::cout << "Unesite elemente niza: ";
for (int i = 0; i < SIZE; i++) {
std::cin >> array[i];
}
ywq(array);
h(array);
return 0;
}
int main() { int c = 0; int n = 0;
std::cout << "Enter the number of rows: ";
std::cin >> c;
std::cout << "Enter the number of columns: ";
std::cin >> n;
int arr[c][n];
for(int i = 0; i < c; i++) {
for(int j = 0; j < n; j++) {
std::cout << "Enter the element at position [" << i << "][" << j << "]: ";
std::cin >> arr[i][j];
}
}
std::cout << "Original matrix:" << std::endl;
for(int i = 0; i < c; i++) {
for(int j = 0; j < n; j++) {
std::cout << arr[i][j] << "\t";
}
std::cout << std::endl;
}
int transposed[n][c];
for(int i = 0; i < n; i++) {
for(int j = 0; j < c; j++) {
transposed[i][j] = arr[j][i];
}
}
std::cout << "Transposed matrix:" << std::endl;
for(int i = 0; i < n; i++) {
for(int j = 0; j < c; j++) {
std::cout << transposed[i][j] << "\t";
}
std::cout << std::endl;
}
return 0;
}
int main() { int c, n;
std::cout << "Enter the number of rows: ";
std::cin >> c;
std::cout << "Enter the number of columns: ";
std::cin >> n;
int **arr = new int*[c];
int **arr2 = new int*[c];
int **sum = new int*[c];
for (int i = 0; i < c; i++) {
arr[i] = new int[n];
arr2[i] = new int[n];
sum[i] = new int[n];
}
std::cout << "Enter elements for the first matrix:" << std::endl;
for (int i = 0; i < c; i++) {
for (int j = 0; j < n; j++) {
std::cout << "Enter the element at position [" << i << "][" << j << "]: ";
std::cin >> arr[i][j];
}
}
std::cout << "Enter elements for the second matrix:" << std::endl;
for (int i = 0; i < c; i++) {
for (int j = 0; j < n; j++) {
std::cout << "Enter the element at position [" << i << "][" << j << "]: ";
std::cin >> arr2[i][j];
}
}
for (int i = 0; i < c; i++) {
for (int j = 0; j < n; j++) {
sum[i][j] = arr[i][j] + arr2[i][j];
}
}
std::cout << "Resultant matrix after addition:" << std::endl;
for (int i = 0; i < c; i++) {
for (int j = 0; j < n; j++) {
std::cout << sum[i][j] << "\t";
}
std::cout << std::endl;
}
return 0;
}
12