【PAT乙级】1053 住房空置率

题目链接:1053 住房空置率

思路

  • 思路并不困难,主要是由两个注意点:
    • %的输出:使用连续两个%,即%%
    • 题目对空置的要求为观察期大于阈值,而不是用电量低于阈值的天数大于阈值。

代码

#include <iostream>
using namespace std;

int main(){
    int N,D,K,pos = 0,emp = 0;
    double e,E;
    cin >> N >> e >> D;
    for(int i=0;i<N;i++){
        cin >> K;
        int count =0;
        for(int j=0;j<K;j++){
            cin >> E;
            if(E < e) count++;
        }
        if(count > K / 2){
            if(K > D) emp++;
            else pos++;
        }
    }
    printf("%.1f%% %.1f%%",pos*100.0/N,emp*100.0/N);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/wulingyu501/article/details/108933802
今日推荐