Unit 38.7

Run Settings
LanguageC
Language Version
Run Command
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int colrow; scanf("%d", &colrow); int **m = malloc(sizeof(int *)*colrow); for (int i = 0; i < colrow; i++) { m[i] = malloc(sizeof(int)*colrow); memset(m[i], 0, sizeof(int) * colrow); } for (int i = 0; i < colrow; i++) { for (int j = 0; i < colrow; j++) { if (i == j) m[i][j] = 1; else m[i][j] = 0; } } for (int i = 0; i < colrow; i++) { for (int j = 0; j < colrow; j++) { printf("%d ", m[i][j]); } printf("\n"); } for (int i = 0; i < colrow; i++) { free(m[i]); } free(m); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines