Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. int n, i;
  3. void funk(int niza[n], int clenovi)
  4. {
  5. int b, zbir=0, c, srednav;
  6. for(i=clenovi-1,b=0,c=0;i>=0;c++,i--,b++)
  7. {
  8. zbir+=niza[c];
  9. if (b==2)
  10. {
  11. srednav=zbir/3;
  12. printf("%d %d %d ", srednav, srednav, srednav);
  13. b=-1;
  14. zbir=0;
  15. Continue;
  16. }
  17. if(i==0&&(clenovi%3==1||clenovi%3==2))
  18. {
  19. if(clenovi%3==1)
  20. {
  21. printf("%d", niza[clenovi-1]);
  22. }
  23. else
  24. {
  25. zbir=0;
  26. zbir+=niza[clenovi-2];
  27. zbir+=niza[clenovi-1];
  28. srednav=zbir/2;
  29. printf("%d %d", srednav, srednav);
  30. }
  31. }
  32. }
  33. }
  34. int main()
  35. {
  36. printf("Vnesete kolku clenovi ke ima nizata:\n");
  37. scanf("%d", &n);
  38. int niza[n];
  39. printf("Vnesete gi vrednostite na nizata:\n");
  40. For (I = 0; I < n; I + +)
  41. {
  42. scanf("%d", &niza[i]);
  43. }
  44. Funk (String, n);
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement