Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Matrice10.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdio.h>
- int main()
- {
- int a[20][20], i, j, n, k, pom;
- printf("Unesi n");
- scanf_s("%d", &n);
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- scanf_s("%d", &a[i][j]);
- }
- }
- printf("Pre sortiranja\n");
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- printf("%d", a[i][j]);
- }
- printf("\n");
- }
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- {
- for (k = j+1; k < n; k++)
- {
- if (a[i][j] > a[i][k])
- {
- pom = a[i][j];
- a[i][j] = a[i][k];
- a[i][k] = pom;
- }
- }
- }
- }
- printf("Posle sortiranja\n");
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- printf("%d", a[i][j]);
- }
- printf("\n");
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment