Advertisement
LegoDrifter

nizi suma i parnost/neparnost

Jan 19th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX 100
  3. int main() {
  4. int i, n, a[MAX], brNep = 0, brPar = 0, sumNep = 0, sumPar = 0;
  5. scanf("%d", &n);
  6. for (i = 0; i < n; ++i)
  7. scanf("%d", &a[i]);
  8. for (i = 0; i < n; ++i) {
  9. if (a[i] % 2) {
  10. brNep++;
  11. sumNep += a[i];
  12. } else {
  13. brPar++;
  14. sumPar += a[i];
  15. }
  16. }
  17. printf("Suma parni: %d\nSuma neparni: %d\n", sumPar, sumNep);
  18. printf("Odnos: %.2f\n", (float)brPar / brNep);
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement