#include <iostream>
#include <cstdlib>
int main() {
const int rows = 4;
const int cols = 3;
char A[rows][cols] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'a', 'b', 'c'}
};
int B[rows][cols];
for (int i = 0; i < rows; ++i)
for (int j = 0; j < cols; ++j)
B[i][j] = atoi(&A[i][j]);
for (int i = 0; i < rows; ++i) {
std::cout << B[i][j] << ' ';
std::cout << std::endl;
}
return 0;
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <cstdlib>
int main() {
const int rows = 4;
const int cols = 3;
char A[rows][cols] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'a', 'b', 'c'}
};
int B[rows][cols];
for (int i = 0; i < rows; ++i)
for (int j = 0; j < cols; ++j)
B[i][j] = atoi(&A[i][j]);
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j)
std::cout << B[i][j] << ' ';
std::cout << std::endl;
}
return 0;
}