求助啊 大佬们 我这个在openjudge上能通过为什么这里就十分啊5555

B2054 求平均年龄

zajiu @ 2024-03-25 08:38:24

#define _CRT_SECURE_NO_WARNINGS
#include <math.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
double q;
int main() {
    int  k,sum=0, i;
    double adv,c=0;
    cin >> k;
    for (i = 1; i <= k; i++)
    {
        cin >> q;
        if (q>=15  &&q<= 25) 
            c += q;
        else break;
    }
    adv = c / k;
    printf("%.2f\n", adv);
   /* cout << adv<< endl;*/
    return 0;
}

by zhangyicheng1010 @ 2024-05-18 13:38:20

@zajiu 把循环里的if和else删掉看行不行


by zhangyicheng1010 @ 2024-05-18 13:41:22

只留``` c += q;


by 0x3E @ 2024-07-06 22:09:30

有点多余...

#include <stdio.h>
using namespace std;

int main() {
    int n, i;
    double sum = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; i ++) {
        int a;
        scanf("%d", &a);
        sum += a;
    }
    printf("%.2lf", sum/n);
    return 0; 
} 

by joe_001 @ 2024-08-08 17:20:34

@0x3E 你看看人家什么头文件?


by jinrunsen @ 2024-08-21 15:25:27

万能头文件解决一切


by lcy20100722 @ 2024-12-18 16:36:07

@jinrunsen 不能解决<windows.h>


by jinrunsen @ 2024-12-26 19:24:52

@lcy20100722 是我格局小了


|