KlanZaTest / TEST

Ovo nam je trenutno najbolji plan za postizanje sto boljih rezultata na testu!!! Ajde da vidimo sta mozemo da uradimo
1 stars 0 forks source link

sada #2

Open Dubaja opened 8 years ago

Dubaja commented 8 years ago

include

void UnesiMatricu(int red, int matrica[red][red]) { printf("Unesi clanove matrice: "); for (int i = 0;i < red; ++i) { for (int j = 0;j < red; ++j) scanf("%d", &matrica[i][j]); printf("\n"); } }

void Transponuj(int red,int m[red][red]) { int m1[red][red]; for (int i = 0;i < red; ++i) for (int j = 0;j < red; ++j) m1[j][i] = m[i][j]; for (int i = 0;i < red; ++i) for (int j = 0;j < red; ++j) m[i][j] = m1[i][j]; }

void IspisiMatricu(int red, int matrica[red][red]) { for (int i = 0;i < red; ++i) { printf("\n"); for (int j = 0;j < red; ++j) printf("%d", matrica[i][j]); } }

Dubaja commented 8 years ago

ovo je samo modul

Dubaja commented 8 years ago

include

include

int AritmetickaSredina(int niz[],int brElem) { int n; for (int i = 0;i < brElem; ++i) n += niz[i]; n /= brElem; return n; }

void GenerisiNiz(int niz[], unsigned int brElem) { for (int i = 0; i < brElem; ++i) { printf("Unesi %d. clan niza: ",i+1); scanf("%d", &niz[i]); printf("\n"); } }

bool ProveriPoredak(int i, int j) { return i <= j; }

void ZameniElementeNiza(int niz[], unsigned int i, unsigned int j) { if (i != j) { int pomocni = niz[i]; niz[i] = niz[j]; niz[j] = pomocni; } }

void BubbleSort2(int niz[], unsigned int brElem) { bool imaZamena = true; unsigned int i = brElem - 1; while (imaZamena == true && i > 0) { imaZamena = false; for (unsigned int j = 0; j < i; ++j) if (!ProveriPoredak(niz[j], niz[j + 1])) { ZameniElementeNiza(niz, j, j + 1); imaZamena = true; } --i; } }

void BinarySearch(int niz[], int donji, int gornji, int kljuc) { int srednji;

if (donji > gornji)
{
    printf("\nBroj nije pronadjen.\n");
    return;
}
srednji = (gornji + donji) / 2;
if (niz[srednji] == kljuc)
{
    printf("\nBroj je pronadjen u nizu i ima indeks: %d\n", srednji);
}
else if (niz[srednji] > kljuc)
{
    BinarySearch(niz, donji, srednji - 1, kljuc);
}
else if (niz[srednji] < kljuc)
{
    BinarySearch(niz, srednji + 1, gornji, kljuc);
}

}

Dubaja commented 8 years ago

modul za 2. zadatak

Dubaja commented 8 years ago

pardon za 3. zadatak je

milan-sas commented 8 years ago

Ocemo imati svi zajedno 100 bodova?