Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning (disable: 4996)
- #include "stdafx.h"
- #include <stdlib.h>
- #include<stdio.h>
- FILE *fd;
- FILE *fp;
- int main()
- {
- double **A, *x, *y;
- int n, m;
- if (!(fd = fopen("dane.txt", "r")))
- {
- printf("Blad wczytywania danych");
- exit(0);
- }
- fp = fopen("zapis.txt", "w");
- fscanf(fd, "%d", &n);
- fscanf(fd, "%d", &m);
- printf("Wypis Macierzy A: \n");
- A = malloc(m * sizeof(double));
- x = malloc(m * sizeof(double));
- y = malloc(m * sizeof(double));
- for (int i = 0; i < n;i++)
- {
- A[i] = malloc(n * sizeof(double));
- for (int j = 0;j < m;j++)
- {
- fscanf(fd, "%lf", &A[i][j]);
- printf("%lf ", A[i][j]);
- }
- printf("\n");
- }
- fprintf(fp, "Wektor x:\n");
- printf("---------------------------------------------------\nWektor x:\n");
- for (int i = 0; i < m; i++)
- {
- x[i] = A[0][i];
- printf("%lf ", x[i]);
- fprintf(fp, "%lf ", x[i]);
- }
- printf("\n---------------------------------------------------\nWektor y:\n");
- fprintf(fp, "\nWektor y:\n");
- for (int i = 0; i < m; i++)
- {
- y[i] = A[n-1][i];
- printf("%lf ", y[i]);
- fprintf(fp, "%lf ", y[i]);
- }
- printf("\n");
- fclose(fp);
- fclose(fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement