jun-csbio / CClass_ZJUT

CClass_ZJUT
1 stars 0 forks source link

加奇数成绩,以及1+(1+2)+...+(1+2+...+n) #34

Open sq4250 opened 1 year ago

sq4250 commented 1 year ago
#include<stdio.h>
long long int xuehao[100];int chengji[100],sum=0,n;
int main(){
    printf("renshu:");
    scanf("%d",&n);
    printf("xuehao:");
    for(int i=0;i<n;i++)scanf("%lld",&xuehao[i]);
    printf("chengji:");
    for(int i=0;i<n;i++)scanf("%d",&chengji[i]);
    for(int i=0;i<n;i++)if(xuehao[i]%2)sum+=chengji[i];
    printf("%d\n",sum);
    return 0;
}
sq4250 commented 1 year ago
#include<stdio.h>
int nn(int n){int a=0;for(int i=1;i<=n;i++)a+=i;return a;}
int main(){
    int n,sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)sum+=nn(i);
    printf("%d",sum);
    return 0;
}
sq4250 commented 1 year ago
#include<stdio.h>
int main(){
    int n,sum1=0,sum2=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){sum1+=i;sum2+=sum1;}
    printf("%d\n",sum2);
    return 0;
}