Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright 2021 by cmargery
- #include <stdio.h>
- #include <stdlib.h>
- #define HEIGHT 100
- #define WIDTH 100
- int input_n();
- void input(int **a, int n, int m);
- void input_n_m(int *n, int *m);
- int main() {
- int n , m;
- input_n_m(&n, &m);
- int **A;
- A=(int**)malloc(n*sizeof(int*));
- for (int i = 0; i < n; ++i)
- A[i] = (int*)malloc(n*sizeof(int));
- input(A, n, n);
- //for (int i = 0; i < n; ++i)
- //free(A[i]);
- //free(A);
- return 0;
- }
- int input_n() {
- char c;
- int n;
- if (scanf("%d%c", &n, &c) == 2 && c == '\n' && n > 0 && n <= 4) {
- } else {
- n = 0;
- }
- return n;
- }
- void input_n_m(int *n, int *m) {
- char c;
- if (scanf("%d %d%c", n, m, &c) == 3 && c == '\n' && *n > 0 && *m > 0) {
- } else {
- printf("n/a");
- }
- }
- void input(int **a, int n, int m) {
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < n; ++i) {
- char c;
- if (scanf("%d%c", a+i+j, &c) != 2 && c != ' ') {
- break;
- } else {
- printf("%d", a[i][j]);
- //continue;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement