CSP 202206-1 归一化处理

2023-09-10 08:54:44 浏览数 (1)

 答题

代码语言:javascript复制
#include<iostream>
#include<cmath>
using namespace std;

int main() {
    int n;
    double variance=0,average=0;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i  ){
        cin>>a[i];
        average =a[i];
    }
    average=average/n;
    for(int i=0;i<n;i  ){
        variance =(a[i]-average)*(a[i]-average);
    }
    variance/=n;
    for(int i=0;i<n;i  ){
        cout<<(a[i]-average)/sqrt(variance)<<endl;
    }
}

0 人点赞