Merge lp:~yani-kathy/marathon/kbert-yani into lp:marathon

Proposed by Yanina Aular (Vauxoo)
Status: Merged
Merged at revision: 32
Proposed branch: lp:~yani-kathy/marathon/kbert-yani
Merge into: lp:marathon
Diff against target: 66 lines (+49/-0)
3 files modified
.bzrignore (+1/-0)
kbert/in.txt (+10/-0)
kbert/kbert.cpp (+38/-0)
To merge this branch: bzr merge lp:~yani-kathy/marathon/kbert-yani
Reviewer Review Type Date Requested Status
Yanina Aular (Vauxoo) (community) Approve
Review via email: mp+191151@code.launchpad.net

Description of the change

Se termina el ejercicio del juego kbert, se ignoran los archivos a.out ya que son los ejecutables estandar.

To post a comment you must log in.
Revision history for this message
Yanina Aular (Vauxoo) (yanina-aular) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2013-10-15 10:49:41 +0000
4@@ -0,0 +1,1 @@
5+**/a.out
6
7=== added directory 'kbert'
8=== added file 'kbert/a.out'
9Binary files kbert/a.out 1970-01-01 00:00:00 +0000 and kbert/a.out 2013-10-15 10:49:41 +0000 differ
10=== added file 'kbert/in.txt'
11--- kbert/in.txt 1970-01-01 00:00:00 +0000
12+++ kbert/in.txt 2013-10-15 10:49:41 +0000
13@@ -0,0 +1,10 @@
14+5
15+5
16+3 8
17+9 1 0
18+1 6 5 5
19+2 8 1 9 1
20+2
21+1
22+98 97
23+0
24
25=== added file 'kbert/kbert.cpp'
26--- kbert/kbert.cpp 1970-01-01 00:00:00 +0000
27+++ kbert/kbert.cpp 2013-10-15 10:49:41 +0000
28@@ -0,0 +1,38 @@
29+#include <iostream>
30+
31+using namespace std;
32+
33+int num, m[102][102], maxi = 0, acum=0;
34+/*Recorrido en preorden*/
35+int kbert(int i, int j){
36+
37+ if(i == num || j > i){
38+ if( maxi < acum)
39+ maxi = acum;
40+ return 0;
41+ }
42+ acum += m[i][j];
43+ kbert(i+1, j+1);
44+ kbert(i+1, j);
45+ acum -= m[i][j];
46+}
47+
48+
49+int main(){
50+
51+ cin >> num;
52+
53+ while(num != 0){
54+
55+ for(int i = 0; i < num; i++)
56+ for(int j = 0; j <= i; j++)
57+ cin >> m[i][j];
58+
59+ kbert(0,0);
60+ cout << maxi << endl;
61+ maxi = 0; acum = 0;
62+ cin >> num;
63+ }
64+
65+ return 0;
66+}

Subscribers

People subscribed via source and target branches

to all changes: