Demo entry 6838146

002

   

Submitted by anonymous on Jun 11, 2019 at 09:31
Language: C. Code size: 262 Bytes.

#include<stdio.h>
int main()
{
    int i=1,sum=0,n,k;//以k为桥梁
    printf("请输入一个奇数:");
    scanf("%d",&n);
    while(i<=n)
    {
        for(k=1;k<=i;k=k+2)
            sum=sum+k;
        i=i+2;
    }
    printf("最终相加结果为:%d\n",sum);
    return 0;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).