
C/C++
C++ задача (на фотой)
Помогите сделать задачу на фото на языке с++, надо делать без лишних библиотек, только стандартные библиотеки, и надо сделать с циклом for пожалуйста 

А задача в чём состоит? Просто матрицу вывести? Тогда так вот можно:
#include <iomanip>
#include <iostream>
using namespace std; int main()
{ int i, j, a[4][4] = {{1, 3, 6, 10}, {2, 5, 9, 13},
{4, 8, 12, 15}, {7, 11, 141, 16}};
for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++)
cout << setw(4) << a[i][j]; cout << endl; }
cin.get(); cin.get(); return 0; }
#include <iomanip>
#include <iostream>
using namespace std; int main()
{ int i, j, a[4][4] = {{1, 3, 6, 10}, {2, 5, 9, 13},
{4, 8, 12, 15}, {7, 11, 141, 16}};
for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++)
cout << setw(4) << a[i][j]; cout << endl; }
cin.get(); cin.get(); return 0; }

Roman Sadalsky
Спасибо, но можно пожалуйста без iomanip
#include <iostream>
int main(){
int a[4][4]={1,3,6,10,2,5,9,13,4,8,12,15,7,11,141,16};
for(int (&i)[4]:a){for(int j:i)std::cout<<j<<'\t'; std::cout<<'\n';}}
int main(){
int a[4][4]={1,3,6,10,2,5,9,13,4,8,12,15,7,11,141,16};
for(int (&i)[4]:a){for(int j:i)std::cout<<j<<'\t'; std::cout<<'\n';}}
#include
using namespace std;
int main()
{
int str{ 1 }, cof, ii;
for (int i = 0; i < 4; i++)
{
str += i; cof = str;
for (int j = 0; j < 4; j++)
{
auto foo = [&]() {return ii > 4 ? 4 : ii < 2 ? 2 : ii; };
i < 2 ? ii = i + j + 1 : ii = 6-j-(i>2);
cout
#include
#include
int main() {
int n;
std::cin >> n;
int matrix[n][n];
int startX = 0, startY = 0;
int currentX = startX, currentY = startY;
for (int i = 1; i = n || currentY - 1 < 0) { //переход на следующую диагональ
if (startY + 1 >= n) {
startX = startX + 1;
startY = n - 1;
} else {
startX = 0;
startY = startY + 1;
}
currentX = startX;
currentY = startY;
} else {
currentX++;
currentY--;
}
}
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) {
std::cout