2nd_Sem_Bogachev/2025.03.21/dist/Windows/a09.c
AZEN-SGG 2d77179904 chore(cleanup): replace legacy Matvei project with updated Linux-based version
- Removed obsolete Matvei source files (tasks 01–04, array/matrix/io_status
  modules, Makefile)
- Introduced new Linux-compatible structure in Linux/Matvei
- Updated build logic via new Makefile
- Adjusted .gitignore to exclude new artifacts
2025-03-25 23:35:44 +03:00

67 lines
1.3 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "array_io.h"
#include "io_status.h"
#include "solve.h"
/* ./a.out m n p k [filename] */
int main(int argc, char *argv[])
{
double t, *a;
int m, n, p, k, res, task = 9;
char *name = 0;
if (!((argc == 5 || argc == 6) &&
sscanf(argv[1], "%d", &m) == 1 &&
sscanf(argv[2], "%d", &n) == 1 &&
sscanf(argv[3], "%d", &p) == 1 &&
sscanf(argv[4], "%d", &k) == 1 &&
k >= 0 && k <= 4 && (!(k == 0 && argc != 6))))
{
printf("Usage: %s m n p k [filename]\n", argv[0]);
return 1;
}
if (argc == 6) name = argv[5];
a = (double *)malloc(m * n * sizeof(double));
if (!a)
{
printf("Not enough memory\n");
return 2;
}
if (name)
{ /* из файла */
io_status ret;
ret = read_matrix(a, m, n, name);
do {
switch (ret)
{
case SUCCESS:
continue;
case ERROR_OPEN:
printf("Cannot open %s\n", name);
break;
case ERROR_READ:
printf("Cannot read %s\n", name);
}
free(a);
return 3;
} while (0);
} else init_matrix(a, m, n, k);
printf("Matrix:\n");
print_matrix(a, m, n, p);
t = clock();
res = t9_solve(a, m, n);
t = (clock() - t) / CLOCKS_PER_SEC;
printf("New matrix:\n");
print_matrix(a, m - 1, n - 1, p);
printf ("%s : Task = %d Result = %d Elapsed = %.2f\n", argv[0], task, res, t);
free(a);
return 0;
}