Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fajlovi 4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdio.h>
- int main()
- {
- int i = 0, j;
- int brojevi[80];
- FILE *ulaz = fopen("ulaz.txt", "r");
- FILE *izlaz = fopen("izlaz.txt", "w");
- int min = 0, pom = 0;
- while(!feof(ulaz))
- {
- fscanf(ulaz, "%d", &brojevi[i]);
- i++;
- }
- min = brojevi[0];
- for (i = 0; i < 5; i++)
- {
- for (j = i + 1; j < 5; j++)
- {
- if (brojevi[i] > brojevi[j])
- {
- pom = brojevi[i];
- brojevi[i] = brojevi[j];
- brojevi[j] = pom;
- }
- }
- }
- for (i = 0; i < 5; i++)
- {
- printf("%d ", brojevi[i]);
- fprintf(izlaz, "%d\n", brojevi[i]);
- }
- fclose(ulaz);
- fclose(izlaz);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement