Advertisement
lazar955

Untitled

May 8th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include<stdio.h>
  4. #include<string.h>
  5. #include<stdlib.h>
  6. typedef int NIZ[100];
  7.  
  8. void unosUNiz(NIZ niz, int *brel){
  9. char odgovor = ' ';
  10. int broj;
  11.  
  12. while (odgovor != 'n')
  13. {
  14. printf("Unesi broj: ");
  15. scanf("%d", &broj);
  16.  
  17. niz[*brel] = broj;
  18.  
  19. (*brel)++;
  20.  
  21. printf("da li zelite da nastavite? Y/N\n");
  22. fflush(stdin);
  23. scanf("%c", &odgovor);
  24. }
  25.  
  26. }
  27.  
  28. void prikazi(NIZ niz, int brel){
  29. int i;
  30. for (i = 0; i < brel; i++)
  31. {
  32. printf("%d ", niz[i]);
  33. }
  34. printf("\n");
  35. }
  36.  
  37.  
  38.  
  39. void unesiNaPocetak(NIZ niz, int *brel){
  40. int i;
  41. int broj;
  42. for (i = *brel; i >= 0; i--)
  43. {
  44. niz[i] = niz[i - 1];
  45. }
  46.  
  47. printf("Unesi broj: ");
  48. scanf("%d", &broj);
  49. niz[0] = broj;
  50.  
  51. (*brel)++;
  52. }
  53.  
  54. void maxEle(NIZ niz, int brel){
  55. int i;
  56. int max = niz[0];
  57.  
  58. for ( i = 0; i < brel; i++)
  59. {
  60. if (niz[i] > max){
  61. max = niz[i];
  62. }
  63. }
  64.  
  65. printf("Maximum je %d\n", max);
  66. }
  67.  
  68. int main(void){
  69. NIZ niz;
  70. int brel = 0;
  71.  
  72.  
  73. unosUNiz(niz, &brel);
  74.  
  75. prikazi(niz, brel);
  76.  
  77. unesiNaPocetak(niz, &brel);
  78. prikazi(niz, brel);
  79.  
  80.  
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement