Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <math.h>
- double max(double a, double b) {
- if(a < b) return b;
- return a;
- }
- int main() {
- double val[41];
- double cur_value = -8;
- for(int i = 0; i < 41; i ++)
- {
- val[i] = sin(cur_value*0.6) * 5.0;
- cur_value += 0.4;
- }
- double maximum = -5.0, sum = 0, cnt = 0;
- for(int i = 0; i < 41; i ++)
- {
- maximum = max(maximum, val[i]);
- if(val[i] < 0.0)
- {
- sum += val[i];
- cnt++;
- }
- }
- printf("%.6f\n%.6f\n", maximum, sum/cnt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement