summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-04-23 09:39:26 +0200
committerGitHub <noreply@github.com>2017-04-23 09:39:26 +0200
commitc5c6b09c47d1f195a2cbde881d52915af875a403 (patch)
tree8f2be811353b3625226af99e4451b7fc77476783
parent951a1bb4b9dafb7a368155e066e66133a7d166a4 (diff)
OII 2017
Adesso funziona anche se 1 <= N <= 4
-rw-r--r--lswf.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/lswf.cpp b/lswf.cpp
index 573509b..997902f 100644
--- a/lswf.cpp
+++ b/lswf.cpp
@@ -32,10 +32,19 @@ int main()
int N, i;
in >> N;
int caracts[MAXG], somma = 0, potSomma;
- int lastc = fibonacci(caracts, N);
+ int lastc;
+ if(N > 4)
+ lastc = fibonacci(caracts, N);
+ else {
+ caracts[0] = 1; caracts[1] = 1; caracts[2] = 2; caracts[3] = 3;
+ if(N == 1) lastc = 1;
+ else if(N == 2) lastc = 2;
+ else if(N == 3) lastc = 3;
+ else lastc = 4;
+ }
int* seq = new int[lastc];
- //for(i = 0; i < lastc; i++) cout << caracts[i] << ' '; cout << endl;
+ for(i = 0; i < lastc; i++) cout << caracts[i] << ' '; cout << endl;
seq[0] = 1;
for(i = lastc; i > 0; i--) {
@@ -45,7 +54,11 @@ int main()
seq[i] = 1;
} else seq[i] = 0;
}
- for(i = 0; i < lastc; i++) out << seq[i];
+ for(i = 0; i < lastc; i++) {
+ out << seq[i];
+ cout << seq[i] << ' ';
+ }
+
delete[] seq;
in.close();
out.close();