repo.or.cz
/
C-Programming-Examples.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Added example cbd_triple_int. Finds triples of integers that add up to N.
[C-Programming-Examples.git]
/
cbd_triple_int.c
blob
d161d3fcc2b1753409cb2388c846e03f0282e539
1
/* Find triples of integers that add up to N */
2
3
#include <stdio.h>
4
5
#define N 7
6
7
int
main
()
8
{
9
int
cnt
=
0
,
i
,
j
,
k
;
10
11
for
(
i
=
0
;
i
<=
N
; ++
i
)
12
for
(
j
=
0
;
j
<=
N
; ++
j
)
13
for
(
k
=
0
;
k
<=
N
; ++
k
)
14
if
(
i
+
j
+
k
==
N
)
15
{
16
++
cnt
;
17
printf
(
"%3d%3d%3d
\n
"
,
i
,
j
,
k
);
18
}
19
printf
(
"
\n
Count: %d
\n
"
,
cnt
);
20
return
0
;
21
}