Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- typedef int NIZ[100];
- void unosUNiz(NIZ niz, int *brel){
- char odgovor = ' ';
- int broj;
- while (odgovor != 'n')
- {
- printf("Unesi broj: ");
- scanf("%d", &broj);
- niz[*brel] = broj;
- (*brel)++;
- printf("da li zelite da nastavite? Y/N\n");
- fflush(stdin);
- scanf("%c", &odgovor);
- }
- }
- void prikazi(NIZ niz, int brel){
- int i;
- for (i = 0; i < brel; i++)
- {
- printf("%d ", niz[i]);
- }
- printf("\n");
- }
- void unesiNaPocetak(NIZ niz, int *brel){
- int i;
- int broj;
- for (i = *brel; i >= 0; i--)
- {
- niz[i] = niz[i - 1];
- }
- printf("Unesi broj: ");
- scanf("%d", &broj);
- niz[0] = broj;
- (*brel)++;
- }
- void maxEle(NIZ niz, int brel){
- int i;
- int max = niz[0];
- for ( i = 0; i < brel; i++)
- {
- if (niz[i] > max){
- max = niz[i];
- }
- }
- printf("Maximum je %d\n", max);
- }
- int main(void){
- NIZ niz;
- int brel = 0;
- unosUNiz(niz, &brel);
- prikazi(niz, brel);
- unesiNaPocetak(niz, &brel);
- prikazi(niz, brel);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement