Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include "utils.c"
- int main(int argc, char *argv[])
- {
- struct tm *local;
- time_t start, end;
- time(&start);
- local = localtime(&start);
- printf("# Start time and date: %s", asctime(local));
- int row, col, count = 0;
- double r = (strcmp(argv[1], "-r") == 0) ? strtof(argv[2], NULL) : strtof(argv[4], NULL);
- double t = (strcmp(argv[1], "-t") == 0) ? strtof(argv[2], NULL) : strtof(argv[4], NULL);
- scanf("%d", &row);
- scanf("%d", &col);
- double **rows = (double **)malloc(row * sizeof(double *));
- for (int i = 0; i < row; i++)
- {
- rows[i] = (double *)malloc(sizeof(double) * col);
- }
- for (int i = 0; i < row; i++)
- {
- for (int j = 0; j < col; j++)
- {
- scanf("%lf", &rows[i][j]);
- }
- }
- for (int i = 0; i < row; i++)
- {
- for (int j = 0; j < col; j++)
- {
- if (approxEqual(rows[i][j], r, t))
- {
- count++;
- fprintf(stdout, "r=%d, c=%d: %.6f\n", i, j, rows[i][j]);
- }
- }
- }
- fprintf(stdout, "Found %d approximate matches.\n", count);
- time(&end);
- local = localtime(&end);
- printf("# End time and date: %s", asctime(local));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement