Zerojudge 基礎題庫a148 You Cannot Pass?!

高中時期,不是所有科目都已80,90分為目標了,能過60,不用補考就是世界上最幸福的事了~
這題就是,把成績相加除以成績數,是否大於59?有,恭喜,你過了!!
值得注意的是,大於n包含n歐,所以59分,過!
還有,小心有浮點數
所以用int,不會過喔。

c++ 程式碼:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
using namespace std;

int main(){
    int a;
    double input;
    double ans;
    while(cin >> a){
        ans = 0;
        for (int i = 0; i < a; i++){
            cin >> input;
            ans = ans + input;
        
        }
        if (ans / a <= 59){
            
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
        //cout << ans / a << endl;
    }
    
    
}

留言

這個網誌中的熱門文章

Zerojudge 基礎題庫a004 文文的求婚 (Python)

紙蜻蜓的受風面積與紙蜻蜓落地時間的關係 #1 [實驗歷程與Python Matplotlib]

Zerojudge 基礎題庫a013 羅馬數字 (Python)