Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
- int sredna(int *niza, int n) {
- int brojac = 0;
- for(int i = 0; i < n; i++) {
- int element = abs(niza[i]);
- int prosek = 0;
- for(int j = 0; j < element; j++) {
- int x;
- scanf("%d", &x);
- brojac++;
- prosek += x;
- }
- prosek /= element;
- niza[i] = prosek;
- }
- return brojac;
- }
- int main(int argc, char * argv[]) {
- int n;
- scanf("%d", &n);
- int niza[n];
- for(int i = 0; i < n; i++) {
- scanf("%d", &niza[i]);
- }
- int result = sredna(niza, n);
- printf("%d\n", result);
- for(int i = 0; i < n; i++) {
- printf("%d ", niza[i]);
- }
- }
- /*
- 5
- 1 2 3 4 5
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement