Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication5.cpp: Określa punkt wejścia dla aplikacji konsoli.
- //
- #include "stdafx.h"
- #include <stdlib.h>
- #include<stdio.h>
- #include <math.h>
- FILE *fd;
- double srA(double *d, int n, double e)
- {
- double tmp;
- for(int i=0; i < n+1; i++)
- {
- if (e <= d[i])
- {
- tmp = d[i];
- d[i] = e;
- e = tmp;
- }
- }
- for (int i = 0; i < n+1 ; i++)
- {
- printf("%lf ", d[i]);
- }
- }
- int main()
- {
- double *d,e;
- int n;
- if (!(fd = fopen("dane.txt", "r")))
- {
- printf("Blad wczytywania danych");
- exit(0);
- }
- fscanf(fd, "%d", &n);
- d = malloc(n * sizeof(double));
- printf("Tablica: \n");
- for (int i = 0; i < n;i++)
- {
- fscanf(fd, "%lf", &d[i]);
- printf("%lf ", d[i]);
- }
- printf("\n podaj liczbe ");
- scanf("%lf", &e);
- printf("\n Odwr: \n");
- srA(d, n,e);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement