Advertisement
Guest User

Untitled

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