View Code of Problem 18

#include <iostream>

using namespace std;

int getTime(int n){
    if(n==1||n==2){
        return 0;
    }else if(n>2){
        return (n-2)+getTime(n-2);

    }

}

int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        cout<<getTime(n)<<endl;


    }




    return 0;

}

Double click to view unformatted code.


Back to problem 18