Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <conio.h>
- #include <math.h>
- #include <iostream>
- using namespace std;
- int n = 10;
- FILE *f;
- void sort_wst(int tab[])
- {
- int i, j, temp;
- for (i = 1; i<n; i++)
- {
- temp = tab[i];
- j = i - 1;
- while ((j >= 0) && (tab[j]>temp))
- {
- tab[j + 1] = tab[j];
- j--;
- tab[j + 1] = temp;
- }
- }
- }
- int main()
- {
- int a[10][10], b[10][10], w[10], i, j, k;
- fopen_s(&f, "k.txt", "r");
- for (i = 0; i<10; i++)
- for (j = 0; j<10; j++)
- fscanf_s(f, "%d", &a[i][j]);
- printf("Odczytana macierz:\n");
- for (i = 0; i<10; ++i)
- {
- for (j = 0; j<10; ++j)
- printf("%6d ", a[i][j]);
- printf("\n");
- }
- for (j = 0; j<10; ++j)
- {
- for (i = 0; i<10; ++i)
- w[i] = a[i][j];
- sort_wst(w);
- for (k = 0; k<10; ++k)b[k][j] = w[k];
- }
- printf("\nPosortowana macierz:\n");
- for (i = 0; i<n; i++)
- {
- for (j = 0; j<10; ++j)printf("%6d ", b[i][j]);
- printf("\n");
- }
- int check, buf, iloraz = 1, el=0;
- check = n - 2;
- printf("Sumy:");
- for (int j = 0; j <= n - 2; j++)
- {
- buf = a[0][j];
- for (int i = 0; i <= check; i++)
- el += a[i][j];
- check--;
- printf("%d; ",buf);
- iloraz *= el;
- }
- printf("\nF=%d",iloraz);
- fclose(f);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement