打卡数据生成器

#include 
#include 
#include 
#include 
#include 
using namespace std;
int n,a[10010];
int getmax()
{
    int maxx=0;
    for(int i=1;i<=n;i++)maxx=max(maxx,a[i]);
    return maxx;
}
int getmin()
{
    int minn=2147483647;
    for(int i=1;i<=n;i++)minn=min(minn,a[i]);
    return minn;
}
int getsum()
{
    int sum=0;
    for(int i=1;i<=n;i++)sum+=a[i];
    return sum;
}
int getpsum()
{
    int sum=0;
    for(int i=22;i<=n;i++)sum+=a[i];
    return sum;
}
double getav(){return getsum()*1.0/n;}
double getup(int xx){return (a[xx]-a[xx-1])*100.0/a[xx-1];}
double getupav()
{
    double sum=0;
    for(int i=2;i<=n;i++)sum+=getup(i);
    sum/=(n-1);
    return sum;
}
int getmid()
{
    int b[10010];
    for(int i=1;i<=n;i++)b[i]=a[i];
    sort(b+1,b+n+1);
    return b[(n+1)/2];
}
double getc()
{
    double av=getav(),sum=0;
    for(int i=1;i<=n;i++)sum+=(a[i]-av)*(a[i]-av);
    sum=sum/n*1.0;
    return sum;
}
double getcc(){return sqrt(getc());}
int getbc(){return getmax()-getmin();}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    printf("\n\n2019.x.xx:\n");
    printf("USACO:%d道\n",a[n]);
    printf("单日增长率:%.1f%%\n",getup(n));
    printf("\n\n\n\n\n\n\n\n\n共打卡:%d天\n",n);
    printf("最高每日答题数:%d道\n",getmax());
    printf("最低每日答题数:%d道\n",getmin());
    printf("\n共做题目:%d道\n",getsum());
    printf("入门组题目:36道\n");
    printf("普及组题目:100道\n");
    printf("USACO:%d道\n",getpsum());
    printf("\n平均每日题数:%.1f道\n",getav());
    printf("平均每日增长率:%.1f%%\n",getupav());
    printf("中位数:%d道\n",getmid());
    printf("标准差:%.1f道\n",getcc());
    printf("方差:%.1f道\n",getc());
    printf("极差:%d道\n",getbc()); 
    return 0;
}

转载于:https://www.cnblogs.com/pjykk/p/11234901.html

你可能感兴趣的:(打卡数据生成器)