Quick actions

cmd+k|ctrl+k

Navigation

Languages

코이스터디 모의고사 3

Snippet info

Language

C

Visibility

public

Author

morisumu

Created

2020-11-30T16:10:57Z

Updated

2020-11-30T16:10:57Z

#include <stdio.h>

int main(){
    int n;
    int hab=0;
    scanf("%d",&n);
    int i=n;
    if(n%2==0){
        while(1){
            if(i>0){
                hab=hab+4*i;
            }
            else{
                break;
            }
            i=i-2;
        }
        hab=hab+1;
    }
    else{
        while(1){
            if(i>0){
                hab=hab+4*i;
            }
            else{
                break;
            }
            i=i-2;
        }
    }
    printf("%d",hab);
}
INFO