1 条题解

  • 0
    @ 2023-6-11 12:17:08

    C :

    #include<stdio.h>
    
    void main(){
        int a[11];
        int n,i,c=0,b=0;
        scanf("%d",&n);
        
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        
        for(i=0;i<n;i++){
            if(a[i]>=90){
                c++;
            }
            if(a[i]<60){
                b++;
            }
        }
        
        if(b==0){
            if(c>=5){
                printf("%d",1);
            }else if(c==3||c==4){
                printf("%d",2);
            }else if(c==2){
                printf("%d",3);
            }
        }else{
            printf("%s","no");
        }
    }
    

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	int a[1000],n,i,x = 0,d = 0;
    	cin>>n;
    	for(i = 0;i < n;i++){
    		cin>>a[i];
    		if(a[i] >= 90){
    			x++;
    		}else if(a[i] < 60){
    			d++;
    		}
    	}
    	
    	if(d == 0){
    		if(x == 5){
    			cout<<1<<endl;
    		}else if(x == 3|| x == 4){
    			cout<<2<<endl;
    		}else if(x == 2){
    			cout<<3<<endl;
    		}
    	}else{
    		cout<<"no"<<endl;
    	}
    }
    
    
    

    Python :

    n=int(input())
    s1=list(map(int,input().split()))
    alen=len([item for item in s1 if item<60])
    blen=len([item for item in s1 if item>=90])
    
    if alen>0:
        print("no")
    else:
        if blen>=5:
            print("1")
        elif blen>=3:
            print("2")
        elif blen==2:
            print("3")
        else:
            pass
    
    
    
    • 1

    信息

    ID
    2349
    时间
    1000ms
    内存
    16MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者