5 solutions

  • 3
    @ 2024-3-24 20:04:26
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int n;
        cin>>n;
        int p=n;
        float ans=0,maxn=-1,minn=100;
        while(n--){
            float x;cin>>x;ans+=x;
            maxn=max(x,maxn),minn=min(x,minn);
        }
        printf("%.2f",(ans-maxn-minn)/(p-2.0));
        return 0;
    }
    
    • -2
      @ 2024-4-6 14:04:20
      #include <bits/stdc++.h>
      using namespace std;
      int main(){
          int n;
          cin>>n;
          int p=n;
          float ans=0,maxn=-1,minn=100;
          while(n--){
              float x;cin>>x;ans+=x;
              maxn=max(x,maxn),minn=min(x,minn);
          }
          printf("%.2f",(ans-maxn-minn)/(p-2.0));
          return 0;
      }
      
      • -2
        @ 2024-3-24 15:07:49
        #include <bits/stdc++.h>
        using namespace std;
        int main(){
            int n;
            cin>>n;
            int p=n;
            float ans=0,maxn=-1,minn=100;
            while(n--){
                float x;cin>>x;ans+=x;
                maxn=max(x,maxn),minn=min(x,minn);//求最大最小
            }
            printf("%.2f",(ans-maxn-minn)/(p-2.0));
            return 0;
        }
        
        • -3
          @ 2024-3-24 10:33:12
          #include <bits/stdc++.h> 
          using namespace std; 
          int main() { 
          int i,n,min,max; 
          double sum=0,avg,m[10001]; 
          cin>>n; 
          for(i=1;i<=n;i++)cin>>m[i];
          //数组赋值 
          min=m[1]; 
          for(i=1;i<=n;i++)if(min>m[i])min=m[i];
          //找出最小的数组元素              
          max=m[1]; 
          for(i=1;i<=n;i++)if(max<m[i])max=m[i];
          //找出最大的数组元素
          for(i=1;i<=n;i++)sum+=m[i];
          //数组元素累加求和 
          avg=(sum-min-max)/(n-2); 
          printf("%.2lf",avg); 
          return 0; 
          }
          
          • -5
            @ 2024-2-24 20:22:05
            
            

            #include <bits/stdc++.h> using namespace std; int main() { int i,n,min,max; double sum=0,avg,m[10001]; cin>>n; for(i=1;i<=n;i++)cin>>m[i];//数组赋值 min=m[1]; for(i=1;i<=n;i++)if(min>m[i])min=m[i];//找出最小的数组元素

            max=m[1]; for(i=1;i<=n;i++)if(max<m[i])max=m[i];//找出最大的数组元素

            for(i=1;i<=n;i++)sum+=m[i];//数组元素累加求和 avg=(sum-min-max)/(n-2); printf("%.2lf",avg); return 0; }

            
            
            • 1

            Information

            ID
            658
            Time
            1000ms
            Memory
            125MiB
            Difficulty
            5
            Tags
            (None)
            # Submissions
            428
            Accepted
            153
            Uploaded By