Last active
December 18, 2015 11:59
-
-
Save boxp/5779579 to your computer and use it in GitHub Desktop.
プログラム基礎Ⅱの小テストを変数無しで解いてみる試みその1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int sum(const int num[],const int count,const int result){ | |
if (count == 0) { | |
return result + num[count]; | |
} else { | |
sum(num,(count-1),(result + num[count])); | |
} | |
} | |
int main(void) | |
{ | |
const int num[10] = {10,9,8,7,6,5,4,3,2,1}; | |
printf("sum = %d\n", sum(num,9,0)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment