anon20016

Untitled

Jan 15th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. // Counts number of odd elements.a - array, n - size of array
  6. int cd(int * arr, int n){
  7. int i, c = 0;
  8. for(i = 0; i < n; i++){
  9. if(arr[i] % 2 == 0){
  10. c++;
  11. }
  12. }
  13. return c;
  14. }
  15.  
  16.  
  17. int sumeven(int * arr, int n){
  18. int j, z, s = 0;
  19. for(j = 0; j < n; j++){
  20. if(arr[j] % 2 != 0){
  21. s = s + arr[j];
  22. }
  23. }
  24. return s;
  25. }
  26.  
  27. int count(int * a, int n){
  28. int z, y = 0;
  29. for(z = 0; z < n - 1; z++){
  30. if (a[z] % 5 == 0 || a[z + 1] % 5 == 0){
  31. y++;
  32. }
  33. }
  34. return y;
  35. }
  36.  
  37. int mul3 (int * a, int n){
  38. int i, c = 1;
  39. for(i = 0; i < n; i++){
  40. if(a[i] % 3 == 0){
  41. c = c * a[i];
  42. }
  43. }
  44. return c;
  45. }
  46.  
  47. int main(){
  48. int a[100], n, i;
  49. scanf("%i", &n);
  50. for (i = 0; i < n; i++){
  51. scanf("%i", &a[i]);
  52. }
  53. printf("%o\n", mul3(a, n));
  54. }
Advertisement
Add Comment
Please, Sign In to add comment