Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void citaj_niz(int *niz, int *n);
- void pisi_niz(int *niz, int n);
- void sort(int *niz, int n);
- int main(int argc, char **argv)
- {
- int niz[100], n;
- citaj_niz(niz, &n);
- sort(niz, n);
- pisi_niz(niz, n);
- getchar();
- return 0;
- }
- void citaj_niz(int *niz, int *n){
- printf("Koliko elemenata ima niz? ");
- scanf("%d", n);
- int i;
- printf("Unesi elemente niza\n");
- for (i=0; i<*n;printf("%d. element ", i+1), scanf("%d", &niz[i]), i++);
- }
- void sort(int *niz, int n){
- int i, j, x;
- for (i=0; i<n-1; i++)
- for(j=i+1; j<n; j++)
- if (niz[j]<niz[i]) {
- x=niz[i];
- niz[i]=niz[j];
- niz[j]=x;
- }
- }
- void pisi_niz(int *niz, int n){
- int i;
- printf("Sortirani niz je:\n");
- for (i=0; i<n; printf("%d ", niz[i]), i++);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement