Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int count = 1;
- double *array = (double*)malloc(count*sizeof(double));
- int n=0;
- double last=0;
- while(last>=0){
- scanf("%lf",&last);
- if(last>=0){
- count++;
- array = (double*)realloc(array, count*sizeof(double));
- array[n]=last;
- n++;
- }
- }
- double sum=0;
- double smallsum=0;
- for(int i=0;i<=n;i++){
- sum=sum+array[i];
- }
- double mittelwert=sum/(n);
- for(int i=0;i<=n;i++){
- if(array[i]<mittelwert){
- smallsum=smallsum+array[i];
- }
- }
- printf("%.2f",smallsum);
- free(array);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment