online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <vector> #include <iomanip> void printDiamond(const std::vector<std::vector<int>>& matrix) { int n = matrix.size(); // Верхняя часть ромба for (int i = 0; i < n; ++i) { // Печатаем пробелы std::cout << std::string(2 * (n - i - 1), ' '); // Печатаем элементы for (int j = 0; j <= i; ++j) { std::cout << std::setw(4) << matrix[i-j][j]; } std::cout << std::endl; } // Нижняя часть ромба for (int i = 1; i < n; ++i) { // Печатаем пробелы std::cout << std::string(2 + 2 * (i - 1), ' '); // Печатаем элементы for (int j = 0; j < n - i; ++j) { std::cout << std::setw(4) << matrix[n-j-1][i+j]; } std::cout << std::endl; } } int main() { int n = 5; // Инициализация массива std::vector<std::vector<int>> matrix(n, std::vector<int>(n)); // Ввод значений массива //std::cout << "Введите значения массива:" << std::endl; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { //std::cin >> matrix[i][j]; matrix[i][j] = 10+10*i+ 1 + j; } } // Вывод исходного массива std::cout << "\nИсходный массив:" << std::endl; for (const auto& row : matrix) { for (int num : row) { std::cout << num << " "; } std::cout << std::endl; } // Вывод ромба std::cout << "\nРомб:" << std::endl; printDiamond(matrix); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue