#35239: C++解:利用陣列


a0987659591@gmail.com (李承恩)

School : 國立中正大學
ID : 159451
IP address : [140.123.3.84]
Last Login :
2024-04-12 00:47:23
a148. You Cannot Pass?! | From: [220.142.61.84] | Post Date : 2023-05-18 02:28

#include<bits/stdc++.h>
using namespace std;
int a[10005];     //陣列設在全域
int main(){
    int n;
    while(cin>>n){
        double sum=0;    //迴圈裡設定sum為double型態,否則sum會被強制轉為int型態,然後記得歸0
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
        }
        if((sum/n)>59) cout<<"no\n";
        else cout<<"yes\n";
    }
}

 
ZeroJudge Forum