航電oj2013-2015 參考代碼

2013 蟠桃大會

#define _CRT_SECURE_NO_WARNINGS 1ide

#include <stdio.h>code

int main()
{it

int n,sum,i;
while(scanf("%d",&n)!=EOF)
{
    sum = 1;
    if(n>1 && n<30)
    {
        for(i=1; i<n; i++)
        {   
            sum = 2*(sum+1);
        }
        printf("%d\n",sum);
    }
}
return 0;

}io

-----------------------------------------------

2014 評委打分

#define _CRT_SECURE_NO_WARNINGS 1class

#include <stdio.h>di

int main()
{view

int n,i;
double min,max,sum,avg;
double arr[100];
while(scanf("%d",&n)!=EOF)
{
    if(n>2 && n<=100)
    {
        scanf("%lf",&arr[0]);//第一次的成績
        sum = min = max = arr[0];
        for(i=1; i<n; i++)
        {
            scanf("%lf",&arr[i]);
            if(arr[i]>max)
                max = arr[i];
            if(arr[i]<min)
                min = arr[i];
            sum += arr[i];
        }
        avg = (sum - min - max)/(n-2);
        printf("%.2lf\n",avg);
    }       
}
return 0;

}vi

-----------------------------------------------

2015 偶數求和

#define _CRT_SECURE_NO_WARNINGS 1while

#include <stdio.h>co

int main()
{

int n,m,i,j,sum,count;
while(scanf("%d%d",&n,&m)!=EOF)
{
    for(i=1; i<=n;)
    {
        sum = 0;
        count =0;
        for(j=1; j<=m&&i<=n; j++)
        {
            sum += i*2; 
            count++;
            i++;
        }   
        printf("%d",sum / count);
        if(i<=n)
            printf(" ");
    }
    printf("\n");
}
return 0;

}

相關文章
相關標籤/搜索