top1编程
← 返回题目
题解

【入门】区间分数

1 条题解

  • 0
    @ 2026-7-28 22:10:15
    #include<bits/stdc++.h>
    using namespace std;
    bool cmp(int a,int b){
    	if(a>b){
    		return true;
    	}else{
    		return false;
    	}
    }
    int main() {
    		int n,a[110],c = 0,x,y;
    		cin>>n;
    		for(int i = 1; i <= n; i++) {
    			cin>>a[i];
    		}
    		cin>>x>>y;
    		sort(a+1,a+1+n,cmp);
    		for(int i = 1; i <= n; i++) {
    			if(a[i] >= x && a[i] <= y) {
    				cout<<a[i]<<" ";
    				c++;
    			}
    		}
    		cout<<endl;
    		cout<<c;
    	return 0;
    }
    
    • 1